Refactor GridScheduleGenerator and related components to improve cursor management and group handling
ci / build-backend (push) Successful in 1m17s
ci / build-frontend (push) Successful in 56s
ci / tests (push) Successful in 1m29s
ci / sonar (push) Successful in 3m34s

Updated the GridScheduleGenerator to reset cursors for slots with no aired positions, ensuring proper state management during rebuilds. Introduced a new method, ResetUnairedCursorsAsync, to handle cursor resets effectively. Enhanced the handling of interstitial groups in the scheduling process, preventing them from being included in slots or fallback groups. Updated related tests to verify the correct behavior of these changes, ensuring robust scheduling logic and accurate group categorization.
This commit is contained in:
Leonid Pershin
2026-07-30 09:55:14 +03:00
parent 5032614773
commit 398b60facc
14 changed files with 317 additions and 31 deletions
@@ -228,6 +228,44 @@ public class GenerateGridTests
Assert.Equal("Сериалы", morning.GroupName);
}
[Fact]
public async Task InterstitialGroup_GoesNeitherIntoSlots_NorIntoFallback()
{
// Группа рекламы — материал для стыков. По размеру она бьёт любую библиотеку, поэтому
// раньше выигрывала каждую полосу без предпочтения по типу и становилась аварийной:
// в эфир уходила полоса роликов, подписанная как программа.
var fixture = new TestDb();
var series = Playable("Сериал", ShowKind.Series, 40, 25);
var films = Films(8, 100);
var ads = Enumerable
.Range(0, 60)
.Select(i => Playable($"Ролик {i}", ShowKind.Interstitial, 1, 1))
.ToList();
var adsGroup = GroupOf("Реклама", [.. ads.Select(a => a.Show.Id)]);
var (channelId, _) = await SeedChannelAsync(
fixture,
[series.Show, .. films.Shows, .. ads.Select(a => a.Show)],
[.. series.Assets, .. films.Assets, .. ads.SelectMany(a => a.Assets)],
[
GroupOf("Сериалы", series.Show.Id),
GroupOf("Фильмы", [.. films.Shows.Select(s => s.Id)]),
adsGroup,
]
);
var plan = await PlanAsync(
fixture,
channelId,
GridProfileKind.Mixed,
GridGenerationMode.Rebuild
);
Assert.DoesNotContain(plan.Slots, s => s.GroupId == adsGroup.Id);
Assert.NotNull(plan.FallbackGroupId);
Assert.NotEqual(adsGroup.Id, plan.FallbackGroupId);
}
[Fact]
public async Task ChildrenBand_SkipsAdultGroup()
{