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:
@@ -42,7 +42,8 @@ public class JunctionFillerTests
|
||||
PlanningTimeWindow? window = null,
|
||||
string? choiceKey = null,
|
||||
int choiceWeight = 1,
|
||||
int poolSize = 8
|
||||
int poolSize = 8,
|
||||
int nearHourMinutes = 0
|
||||
) =>
|
||||
new(
|
||||
Guid.NewGuid(),
|
||||
@@ -55,6 +56,7 @@ public class JunctionFillerTests
|
||||
minMinutesBetween,
|
||||
chance,
|
||||
window,
|
||||
nearHourMinutes,
|
||||
choiceKey,
|
||||
choiceWeight
|
||||
);
|
||||
@@ -234,6 +236,58 @@ public class JunctionFillerTests
|
||||
Assert.DoesNotContain(result.Items, i => i.Kind == PlannedItemKind.Ad);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NearHour_SkipsAwayFromRoundHour()
|
||||
{
|
||||
// Серии по 20 минут: стыки приходятся на 18:20 и 18:40 — сигналу точного времени там не место.
|
||||
var element = Series(3, 20, out _);
|
||||
var result = Run(
|
||||
Slot(
|
||||
element,
|
||||
3,
|
||||
between: new PlanningJunction(Guid.NewGuid(), [Ads(1, nearHourMinutes: 5)])
|
||||
)
|
||||
);
|
||||
|
||||
Assert.DoesNotContain(result.Items, i => i.Kind == PlannedItemKind.Ad);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NearHour_PlacesOnTheHour()
|
||||
{
|
||||
// Часовые серии: стыки ровно в 19:00 и 20:00 — врезка с допуском срабатывает на каждом.
|
||||
var element = Series(3, 60, out _);
|
||||
var result = Run(
|
||||
Slot(
|
||||
element,
|
||||
3,
|
||||
between: new PlanningJunction(Guid.NewGuid(), [Ads(1, nearHourMinutes: 5)])
|
||||
)
|
||||
);
|
||||
|
||||
var ads = result.Items.Where(i => i.Kind == PlannedItemKind.Ad).ToList();
|
||||
Assert.Equal(2, ads.Count);
|
||||
Assert.All(ads, ad => Assert.Equal(0, ad.StartsAtUtc.Minute));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NearHour_CountsChannelTime_NotUtc()
|
||||
{
|
||||
// Канал в UTC+3:30: круглый час канала приходится на :30 по UTC, и считать надо по каналу —
|
||||
// «московское время» объявляют в эфире, а не в UTC.
|
||||
var element = Series(3, 60, out _);
|
||||
var result = Run(
|
||||
Slot(
|
||||
element,
|
||||
3,
|
||||
between: new PlanningJunction(Guid.NewGuid(), [Ads(1, nearHourMinutes: 5)])
|
||||
),
|
||||
utcOffsetMinutes: 210
|
||||
);
|
||||
|
||||
Assert.DoesNotContain(result.Items, i => i.Kind == PlannedItemKind.Ad);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Choice_PlacesExactlyOneOfTheFork()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user