PR Gates / CI image pin matches docker/ci (pull_request) Successful in 9s
PR Gates / Docs update reminder (pull_request) Successful in 13s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 1m25s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 1m21s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 7m36s
PR Gates / decisions lifecycle (pull_request) Failing after 14s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been cancelled
Build ErsatzTV Image / Functional E2E (curl contracts) (pull_request) Has been cancelled
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Has been cancelled
Extract the byte-identical PlaybackOrder -> IMediaCollectionEnumerator switch shared by SchedulingEngine.EnumeratorForContent (Scripted) and EnumeratorCache.GetEnumeratorForContent (Sequential/YAML) into one static per-family seam, mirroring #380's ShuffleSourceBuilder. Each engine keeps its own "not supported" warning on the None branch, so the per-engine message is unchanged. Adds ContentEnumeratorBuilderTests pinning the block-shuffle-not-classic trap and the unsupported-order -> None (#70) contract across all 8 unsupported orders. Corrects the testing.scripted-playout-golden-deferred decision record: Scripted's external-process + HTTP pipeline is integration-only (deferred to #563), but the in-process SchedulingEngine it drives IS unit-testable (ScriptedScheduleController is a 1:1 pass-through) -- the earlier "un-golden-able by construction" framing conflated transport with engine. docs/testing.md reframed to match. [decisions-edit] fixes #395 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
48 lines
2.4 KiB
C#
48 lines
2.4 KiB
C#
using ErsatzTV.Core.Domain;
|
|
using ErsatzTV.Core.Interfaces.Scheduling;
|
|
using ErsatzTV.Core.Scheduling.BlockScheduling;
|
|
|
|
namespace ErsatzTV.Core.Scheduling;
|
|
|
|
/// <summary>
|
|
/// Builds the stateless-index <see cref="IMediaCollectionEnumerator" /> for a single content entry from its
|
|
/// <see cref="PlaybackOrder" /> and flat item list.
|
|
/// <para>
|
|
/// Extracted (issue #395) so the Scripted engine (<c>SchedulingEngine.EnumeratorForContent</c>) and the
|
|
/// Sequential/YAML engine (<c>EnumeratorCache.GetEnumeratorForContent</c>) share ONE construction switch
|
|
/// instead of two byte-identical copies. Kept a <c>public static</c> helper with dependencies passed as
|
|
/// parameters, matching the sibling <see cref="ShuffleSourceBuilder" /> / <see cref="MultiPartEpisodeGrouper" />
|
|
/// seams (issue #380).
|
|
/// </para>
|
|
/// <para>
|
|
/// Deliberately per-family and narrow: only <see cref="PlaybackOrder.Chronological" /> and
|
|
/// <see cref="PlaybackOrder.Shuffle" /> are supported, and Shuffle maps to the <em>block</em> variant
|
|
/// <see cref="BlockPlayoutShuffledMediaCollectionEnumerator" /> — NOT Classic's
|
|
/// <see cref="ShuffledMediaCollectionEnumerator" />, which is a different algorithm. Every other order returns
|
|
/// <see cref="Option{A}" />.<c>None</c> so each caller logs its own engine-specific "not supported" warning
|
|
/// (#70); folding the warning in here would lose that per-engine message.
|
|
/// </para>
|
|
/// </summary>
|
|
public static class ContentEnumeratorBuilder
|
|
{
|
|
public static Option<IMediaCollectionEnumerator> ForContent(
|
|
List<MediaItem> items,
|
|
CollectionEnumeratorState state,
|
|
PlaybackOrder playbackOrder,
|
|
bool multiPart)
|
|
{
|
|
switch (playbackOrder)
|
|
{
|
|
case PlaybackOrder.Chronological:
|
|
return new ChronologicalMediaCollectionEnumerator(items, state);
|
|
case PlaybackOrder.Shuffle:
|
|
List<GroupedMediaItem> groupedMediaItems = multiPart
|
|
? MultiPartEpisodeGrouper.GroupMediaItems(items, false)
|
|
: items.Map(mi => new GroupedMediaItem(mi, null)).ToList();
|
|
return new BlockPlayoutShuffledMediaCollectionEnumerator(groupedMediaItems, state);
|
|
default:
|
|
return Option<IMediaCollectionEnumerator>.None;
|
|
}
|
|
}
|
|
}
|