Resolved issue with 24hr/historic price values sometimes being null at source

This commit is contained in:
Dev 2024-05-11 12:22:05 +01:00
parent eadebfb8ff
commit 7b1178abf8
2 changed files with 3 additions and 3 deletions

View File

@ -44,7 +44,7 @@ namespace MarketPriceLookup.Common.Helpers
// iterate over all items returned and filter out bad prices
foreach (var item in parsedResponse.data.items)
{
if (item.historicalPrices.Length == 0)
if (item.historicalPrices == null || item.historicalPrices.Length == 0)
{
LoggingHelpers.LogError($"unable to add item {item.id} {item.name} with no historical prices, ignoring");
continue;
@ -88,7 +88,7 @@ namespace MarketPriceLookup.Common.Helpers
{
Name = item.name,
//Price = price,
Average24hPrice = item.avg24hPrice,
Average24hPrice = item.avg24hPrice ?? 0,
Average7DaysPrice = averagedItemPrice,
PricePoints = item.historicalPrices.Length,
//Trader = trader,

View File

@ -16,7 +16,7 @@ namespace MarketPriceLookup.Common.Helpers
public class Item
{
public string name { get; set; }
public int avg24hPrice { get; set; }
public int? avg24hPrice { get; set; }
public double? changeLast48hPercent { get; set; }
public string id { get; set; }
public HistoricalPrice[] historicalPrices { get; set; }