Refactor GridScheduleGenerator and related components to improve cursor management and group handling
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:
@@ -163,6 +163,46 @@ public sealed class GridScheduleGeneratorIntegrationTests(PostgresFixture fixtur
|
||||
Assert.Equal(aired.EpisodeIndex + 1, firstAfterRebuild.EpisodeIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Канал, который ещё не вышел в эфир: применять сетку можно сколько угодно раз, и каждый раз
|
||||
/// эфир обязан начинаться с начала. Отматывать здесь не к чему — отыгранного нет вовсе, — и без
|
||||
/// сброса курсора второе применение начинало бы сериал с той серии, до которой курсор домотал
|
||||
/// по только что снесённому хвосту.
|
||||
/// </summary>
|
||||
[SkippableFact]
|
||||
public async Task Generate_Rebuild_StartsOver_WhenNothingHasAiredYet()
|
||||
{
|
||||
Skip.IfNot(fixture.Available, "Docker недоступен");
|
||||
|
||||
await using var seedDb = fixture.CreateContext();
|
||||
var world = await SeedAsync(seedDb, episodes: 100);
|
||||
|
||||
await using var first = fixture.CreateContext();
|
||||
await Generator(first).GenerateAsync(world.ChannelId, Now, false, default);
|
||||
|
||||
await using var beforeDb = fixture.CreateContext();
|
||||
// Ничего не отыграно: вся построенная лента — будущее.
|
||||
Assert.Empty(
|
||||
beforeDb.ScheduleEntries.Where(e =>
|
||||
e.ChannelId == world.ChannelId && e.StartsAtUtc < Now
|
||||
)
|
||||
);
|
||||
Assert.True(beforeDb.SlotStates.Single(s => s.SlotId == world.SlotId).NextUnitIndex > 0);
|
||||
|
||||
await using var rebuild = fixture.CreateContext();
|
||||
await Generator(rebuild).GenerateAsync(world.ChannelId, Now, true, default);
|
||||
|
||||
await using var verify = fixture.CreateContext();
|
||||
var firstProgram = verify
|
||||
.ScheduleEntries.Where(e =>
|
||||
e.ChannelId == world.ChannelId && e.Kind == ScheduleEntryKind.Program
|
||||
)
|
||||
.OrderBy(e => e.StartsAtUtc)
|
||||
.First();
|
||||
|
||||
Assert.Equal(0, firstProgram.EpisodeIndex);
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public async Task Generate_CollectionInGroup_StampsCollectionOnEntries()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user