Implement template export/import endpoints and enhance grid generation logic
Added new endpoints for exporting and importing grid configurations in TemplateEndpoints, allowing for better management of template data. Enhanced the GenerateGridCommandHandler to support seasonal layers in grid generation, improving scheduling accuracy during holiday periods. Updated related classes and records to accommodate these changes, ensuring a cohesive integration of new features. Improved documentation for clarity and maintainability.
This commit is contained in:
@@ -391,6 +391,15 @@ public sealed class GridScheduleGenerator(
|
||||
|
||||
var fallback = await LoadFallbackUnitsAsync(channel, template, cancellationToken);
|
||||
|
||||
// Чем добивается шов до круглой отметки: ролики и анонсы стыка канала по умолчанию.
|
||||
var padJunction = BuildJunction(
|
||||
template.DefaultJunctionId,
|
||||
junctions,
|
||||
elementsByGroup,
|
||||
bumperTemplates,
|
||||
Daypart.Day
|
||||
);
|
||||
|
||||
return new PlanningInput(
|
||||
channel.Id,
|
||||
startUtc,
|
||||
@@ -399,10 +408,32 @@ public sealed class GridScheduleGenerator(
|
||||
fallback,
|
||||
_segmentSeconds,
|
||||
channel.UtcOffsetMinutes,
|
||||
grid.Background.Select(s => planned[s]).ToList()
|
||||
grid.Background.Select(s => planned[s]).ToList(),
|
||||
PadUnits(padJunction),
|
||||
padJunction?.MaxTotal ?? PlanningInput.DefaultMaxPad
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ролики и анонсы стыка, распрямлённые в плоский список для добора шва. Заставки сюда
|
||||
/// не попадают: их ассет рендерится под конкретную пару соседей, а шов — это ровно то место,
|
||||
/// где пары ещё нет.
|
||||
/// </summary>
|
||||
private static IReadOnlyList<PadUnit> PadUnits(PlanningJunction? junction) =>
|
||||
junction is null
|
||||
? []
|
||||
: junction
|
||||
.Elements.Where(e => e.Kind != JunctionElementKind.Bumper && e.Units.Count > 0)
|
||||
.SelectMany(e =>
|
||||
e.Units.Select(unit => new PadUnit(
|
||||
unit,
|
||||
e.Kind == JunctionElementKind.Promo
|
||||
? PlannedItemKind.Promo
|
||||
: PlannedItemKind.Ad
|
||||
))
|
||||
)
|
||||
.ToList();
|
||||
|
||||
/// <summary>Разворачивает шаблон стыка для планировщика, включая резерв под заставки.</summary>
|
||||
private PlanningJunction? BuildJunction(
|
||||
Guid? junctionId,
|
||||
@@ -443,6 +474,7 @@ public sealed class GridScheduleGenerator(
|
||||
conditions.TimeWindow is { } window
|
||||
? new PlanningTimeWindow(window.From, window.To)
|
||||
: null,
|
||||
conditions.NearHourMinutes,
|
||||
element.ChoiceKey,
|
||||
element.ChoiceWeight,
|
||||
element.BumperTemplateId,
|
||||
|
||||
Reference in New Issue
Block a user