From eadebfb8ff29bfd239b22affe95f88c2f0b5175d Mon Sep 17 00:00:00 2001 From: Dev Date: Sun, 24 Mar 2024 21:55:20 +0000 Subject: [PATCH] Fix 0 value prices being saved into JSON --- MarketPriceLookup/Program.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MarketPriceLookup/Program.cs b/MarketPriceLookup/Program.cs index d4f3f0d..5e43dbb 100644 --- a/MarketPriceLookup/Program.cs +++ b/MarketPriceLookup/Program.cs @@ -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); }