Auto-tune channels can now carry per-content-source rotation weights (weighted
round-robin, e.g. 3x Show A / 1x Show B) and query corrections (exclude /
add-untagged), supplied at bulk-create time via an optional
`sources: [{sourceId, weight, excluded}]` on each AutoTunedChannelRequest.
Design (Option A, reuse #70): when a source is customized the channel is backed
by a system-owned MultiCollection of per-source SmartCollections carrying the
weights, with PlaybackOrder.WeightedShuffle -- the exact path
WeightedShuffleCollectionEnumerator already consumes. All-default weights keep
the #69 single-SmartCollection fair-share shape.
- Discriminators: TV -> live show_title:"X" (episodes carry no parent-show id in
the index); movies -> stable id:{mediaItemId}.
- Materialization is axis-dependent: TV materializes every base show individually
(un-weighted shows keep per-show fair-share) + a live remainder at weight 1;
MovieGenre materializes only touched movies + one count-weighted remainder.
- Remainder = (base) AND NOT (materialized union excluded) -- a partition.
- New nullable OwnedByChannelId on SmartCollection + MultiCollection
(dual-provider migration); owned rows are hidden from the collection lists and
cascade-cleaned on channel delete.
Tests: AutoTuneAxisMap query/partition units; DB-backed weighted-path handler
tests (TV materialize-all, movie count-remainder, exclusion, no-customization
fallback); delete-cleanup. Docs: decisions.md, domain-model.md, api-conventions.md;
OpenAPI trio regenerated.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
53 lines
2.1 KiB
C#
53 lines
2.1 KiB
C#
using ErsatzTV.Application.Artworks;
|
|
using ErsatzTV.Core.Domain;
|
|
using MediatR;
|
|
|
|
namespace ErsatzTV.Application.Channels;
|
|
|
|
public record CreateAutoTunedChannels(
|
|
int TemplateId,
|
|
string Group,
|
|
List<AutoTuneChannelSelection> Channels) : IRequest<AutoTuneResult>;
|
|
|
|
// The batch-level TemplateId is the default; any per-channel field set here overrides it for that one
|
|
// channel. Advanced/Logo/TemplateId are all optional so the older positional {axis, value, name, number}
|
|
// form (and every existing caller/test) keeps compiling and behaving identically.
|
|
public record AutoTuneChannelSelection(
|
|
AutoTuneAxis Axis,
|
|
string Value,
|
|
string Name,
|
|
string Number,
|
|
int? TemplateId = null,
|
|
ArtworkContentTypeModel Logo = null,
|
|
CreateChannelFromLineupAdvancedOptions Advanced = null,
|
|
List<AutoTuneSourceWeight> Sources = null);
|
|
|
|
// Per-content-source rotation weight + query correction for a weighted auto-tune channel (#425).
|
|
// SourceId is the show id (TV axes) or movie media-item id (movie axis) from the members list (#384).
|
|
// Weight is the relative share of airtime (weighted round-robin; 1 = fair-share). Excluded drops the
|
|
// source entirely. A SourceId that is not in the axis's base set is an "add-untagged" source — materialized
|
|
// like any other. When every entry is Weight 1 and not excluded (and adds nothing), the channel keeps the
|
|
// single-SmartCollection fair-share shape; otherwise it is built as a MultiCollection of per-source
|
|
// SmartCollections carrying the weights.
|
|
public record AutoTuneSourceWeight(int SourceId, int Weight = 1, bool Excluded = false);
|
|
|
|
public record AutoTuneResult(List<AutoTuneChannelOutcome> Results)
|
|
{
|
|
public int CreatedCount => Results.Count(r => r.Status == AutoTuneOutcomeStatus.Created);
|
|
public int SkippedCount => Results.Count(r => r.Status == AutoTuneOutcomeStatus.Skipped);
|
|
public int FailedCount => Results.Count(r => r.Status == AutoTuneOutcomeStatus.Failed);
|
|
}
|
|
|
|
public record AutoTuneChannelOutcome(
|
|
string Name,
|
|
AutoTuneOutcomeStatus Status,
|
|
int? ChannelId,
|
|
string Reason);
|
|
|
|
public enum AutoTuneOutcomeStatus
|
|
{
|
|
Created,
|
|
Skipped,
|
|
Failed
|
|
}
|