Move coins without rank to end of list. Fixes #59

pull/71/head
Miguel Mota 4 years ago
parent 996d842946
commit 26956fcaca

@ -321,6 +321,17 @@ func NewCointop(config *Config) (*Cointop, error) {
ct.filecache.Get(coinscachekey, &allCoinsSlugMap)
}
// fix for https://github.com/miguelmota/cointop/issues/59
// can remove this after everyone has cleared their cache
for _, v := range allCoinsSlugMap {
// Some APIs returns rank 0 for new coins
// or coins with low activity so we need to put them
// at the end of the list.
if v.Rank == 0 {
v.Rank = 10000
}
}
for k, v := range allCoinsSlugMap {
ct.State.allCoinsSlugMap.Store(k, v)
}

@ -20,7 +20,6 @@ func (ct *Cointop) UpdateCoins() error {
var err error
var allCoinsSlugMap map[string]types.Coin
cached, found := ct.cache.Get(cachekey)
_ = cached
if found {
// cache hit
allCoinsSlugMap, _ = cached.(map[string]types.Coin)
@ -49,6 +48,7 @@ func (ct *Cointop) UpdateCoins() error {
// ProcessCoinsMap processes coins map
func (ct *Cointop) processCoinsMap(coinsMap map[string]types.Coin) {
ct.debuglog("processCoinsMap()")
var coins []types.Coin
for _, v := range coinsMap {
coins = append(coins, v)
@ -67,6 +67,15 @@ func (ct *Cointop) processCoins(coins []types.Coin) {
for _, v := range coins {
k := v.Name
// Fix for https://github.com/miguelmota/cointop/issues/59
// some APIs returns rank 0 for new coins
// or coins with low activity so we need to put them
// at the end of the list
if v.Rank == 0 {
v.Rank = 10000
}
ilast, _ := ct.State.allCoinsSlugMap.Load(k)
ct.State.allCoinsSlugMap.Store(k, &Coin{
ID: v.ID,

Loading…
Cancel
Save