Enhance EffectiveGridBuilder to support background slots and improve scheduling logic
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:
@@ -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()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user