Implement template export/import endpoints and enhance grid generation logic
ci / build-backend (push) Successful in 1m31s
ci / build-frontend (push) Successful in 1m5s
ci / tests (push) Successful in 3m54s
ci / sonar (push) Successful in 4m40s

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:
Leonid Pershin
2026-07-28 02:15:04 +03:00
parent 7bee84c548
commit f7e7b5f7c3
45 changed files with 2929 additions and 242 deletions
@@ -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,