Add shared test data builders and Qodana configuration
- Extract per-monitor *TestData helper classes and rework tests to use them - Add boiler run-time tracker abstraction (implementation pending) - Drop unused NordPool init/update-result types and stale PLAN.md - Add qodana.yaml with the inspection set to keep the analysis focused
This commit is contained in:
@@ -26,13 +26,13 @@ public class NordPoolPriceService(Services services, IMapper mapper, ILogger<Nor
|
||||
var nowCet = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, cetTimeZone);
|
||||
var today = DateOnly.FromDateTime(nowCet);
|
||||
|
||||
if (TodayNordPoolPrice?.Prices == null || TodayNordPoolPrice.Prices.Count == 0)
|
||||
if ((TodayNordPoolPrice?.Prices == null || TodayNordPoolPrice.Prices.Count == 0) && ShouldFetchNewPrices(today))
|
||||
{
|
||||
logger.LogInformation("Fetching today's prices from API for CET date: {Today}", today);
|
||||
TodayNordPoolPrice = await FetchPricesForDateWithRetryAsync(today, "today");
|
||||
}
|
||||
|
||||
if (TomorrowNordPoolPrice?.Prices == null || TomorrowNordPoolPrice.Prices.Count == 0)
|
||||
if ((TomorrowNordPoolPrice?.Prices == null || TomorrowNordPoolPrice.Prices.Count == 0) && ShouldFetchNewPrices(today.AddDays(1)))
|
||||
{
|
||||
logger.LogInformation("Fetching tomorrow's prices from API for CET date: {Tomorrow}", today.AddDays(1));
|
||||
TomorrowNordPoolPrice = await FetchPricesForDateWithRetryAsync(today.AddDays(1), "tomorrow");
|
||||
@@ -42,7 +42,7 @@ public class NordPoolPriceService(Services services, IMapper mapper, ILogger<Nor
|
||||
LastFetchedDate = today;
|
||||
}
|
||||
|
||||
public double UpdateCurrentPrice()
|
||||
public void UpdateCurrentPrice()
|
||||
{
|
||||
var index = GetTimeQuarterIndex(DateTime.UtcNow);
|
||||
|
||||
@@ -70,7 +70,10 @@ public class NordPoolPriceService(Services services, IMapper mapper, ILogger<Nor
|
||||
|
||||
DayQuartersIndex = index;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public double GetCurrentPrice()
|
||||
{
|
||||
return CurrentPrice;
|
||||
}
|
||||
|
||||
@@ -106,14 +109,7 @@ public class NordPoolPriceService(Services services, IMapper mapper, ILogger<Nor
|
||||
|
||||
public void RollOverPrices(DateOnly today)
|
||||
{
|
||||
if (TomorrowNordPoolPrice?.Prices is { Count: > 0 })
|
||||
{
|
||||
TodayNordPoolPrice = TomorrowNordPoolPrice;
|
||||
}
|
||||
else
|
||||
{
|
||||
TodayNordPoolPrice = new NordPoolPrice();
|
||||
}
|
||||
TodayNordPoolPrice = TomorrowNordPoolPrice?.Prices is { Count: > 0 } ? TomorrowNordPoolPrice : new NordPoolPrice();
|
||||
|
||||
TomorrowNordPoolPrice = null;
|
||||
|
||||
@@ -215,7 +211,7 @@ public class NordPoolPriceService(Services services, IMapper mapper, ILogger<Nor
|
||||
{
|
||||
var cetTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time");
|
||||
var cetDate = TimeZoneInfo.ConvertTimeFromUtc(utcDate, cetTimeZone);
|
||||
var totalMinutes = (cetDate.Hour * 60) + cetDate.Minute;
|
||||
var totalMinutes = cetDate.Hour * 60 + cetDate.Minute;
|
||||
|
||||
return totalMinutes / NordPoolConsts.MinutesPerInterval;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user