Fix 0 value prices being saved into JSON

This commit is contained in:
Dev 2024-03-24 21:55:20 +00:00
parent e9f1e77cc8
commit eadebfb8ff

View File

@ -47,7 +47,21 @@ namespace MarketPriceLookup
continue;
}
// Sometimes price can be 0, use other prices value
if (priceData.Average24hPrice == 0 && priceData.Average7DaysPrice > 0)
{
priceData.Average24hPrice = priceData.Average7DaysPrice;
}
else if (priceData.Average7DaysPrice == 0 && priceData.Average24hPrice > 0)
{
priceData.Average7DaysPrice = priceData.Average24hPrice;
}
var priceOfItem = Math.Min(priceData.Average7DaysPrice, priceData.Average24hPrice);
if (priceOfItem <= 0)
{
continue;
}
priceList.Add(item.Key, priceOfItem);
}