Refactor UpdateCheapestIntervals logic to return a result object and improve code readability. Introduce CheapestIntervalsUpdateResult model for encapsulating update details and simplify inline tuples.

This commit is contained in:
Marius
2026-03-16 12:00:23 +02:00
parent 53eb53539a
commit 42b1fe3b18
5 changed files with 44 additions and 18 deletions
+3 -2
View File
@@ -40,6 +40,7 @@ public class NordPoolEntityService(IEntityManager entityManager, ILogger<NordPoo
try
{
logger.LogInformation("Creating/re-registering MQTT entity: {EntityId}", nordPoolEntity.EntityId);
await entityManager.CreateEntityAsync(nordPoolEntity);
}
catch (Exception ex)
@@ -310,11 +311,11 @@ public class NordPoolEntityService(IEntityManager entityManager, ILogger<NordPoo
return entries;
}
private static IReadOnlyList<NordPoolDayPrice> MergeTodayTomorrowPrices(
NordPoolPrice? today, NordPoolPrice? tomorrow)
private static List<NordPoolDayPrice> MergeTodayTomorrowPrices(NordPoolPrice? today, NordPoolPrice? tomorrow)
{
var todayList = today?.Prices ?? [];
var tomorrowList = tomorrow?.Prices ?? [];
return todayList
.Concat(tomorrowList)
.Where(p => p?.Start != null)