Enhance EffectiveGridBuilder to support background slots and improve scheduling logic
ci / build-backend (push) Successful in 2m37s
ci / build-frontend (push) Successful in 1m11s
ci / tests (push) Successful in 2m31s
ci / sonar (push) Successful in 6m52s

Updated the EffectiveGridBuilder to return an EffectiveGrid containing both scheduled and background slots, allowing for better management of overlapping content. Refactored the ResolveDay method to handle background slots separately, ensuring they fill gaps in the schedule appropriately. Adjusted related components, including GridScheduleGenerator and SchedulePlanner, to accommodate the new structure and improve overall scheduling accuracy. Enhanced documentation and comments for clarity.
This commit is contained in:
Leonid Pershin
2026-07-28 01:06:29 +03:00
parent e0b85807df
commit 7bee84c548
12 changed files with 512 additions and 58 deletions
@@ -265,13 +265,16 @@ public sealed class GridScheduleGenerator(
CancellationToken cancellationToken
)
{
var scheduled = EffectiveGridBuilder.Build(
var grid = EffectiveGridBuilder.Build(
template,
channel.UtcOffsetMinutes,
channel.DayStartTime,
startUtc,
horizonEnd
);
// Перекрытые слоты фонового слоя разворачиваются так же, как обычные: паузы закрываются
// их контентом, и им нужны и группа, и стратегия, и курсор.
var scheduled = grid.Slots.Concat(grid.Background).ToList();
// Стыки грузим целиком: их немного, а группы врезок надо развернуть тем же проходом,
// что и группы контента. Стыки общие, поэтому фильтра по каналу нет.
@@ -319,7 +322,7 @@ public sealed class GridScheduleGenerator(
.Where(s => slotIds.Contains(s.SlotId))
.ToDictionaryAsync(s => s.SlotId, cancellationToken);
var slots = new List<PlanningSlot>();
var planned = new Dictionary<ScheduledSlot, PlanningSlot>();
foreach (var item in scheduled)
{
var slot = item.Slot;
@@ -343,7 +346,8 @@ public sealed class GridScheduleGenerator(
)
: null;
slots.Add(
planned.Add(
item,
new PlanningSlot(
slot.Id,
item.StartUtc,
@@ -391,10 +395,11 @@ public sealed class GridScheduleGenerator(
channel.Id,
startUtc,
horizonEnd,
slots,
grid.Slots.Select(s => planned[s]).ToList(),
fallback,
_segmentSeconds,
channel.UtcOffsetMinutes
channel.UtcOffsetMinutes,
grid.Background.Select(s => planned[s]).ToList()
);
}