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>
57 lines
2.1 KiB
C#
57 lines
2.1 KiB
C#
using ErsatzTV.Application.Artworks;
|
|
using ErsatzTV.Application.Channels;
|
|
using ErsatzTV.Core.Domain;
|
|
|
|
namespace ErsatzTV.Controllers.Api.Requests;
|
|
|
|
public record PreviewAutoTuneChannelsRequest(
|
|
List<AutoTuneAxis> Axes,
|
|
int MinItems,
|
|
int StartingNumber)
|
|
{
|
|
public PreviewAutoTuneChannels ToCommand() => new(Axes, MinItems, StartingNumber);
|
|
}
|
|
|
|
public record CreateAutoTunedChannelsRequest(
|
|
int TemplateId,
|
|
string Group,
|
|
List<AutoTunedChannelRequest> Channels)
|
|
{
|
|
public CreateAutoTunedChannels ToCommand() =>
|
|
new(TemplateId, Group, (Channels ?? []).Select(c => c.ToCommand()).ToList());
|
|
}
|
|
|
|
// Optional per-channel overrides (DetailPanel, #385): TemplateId overrides the batch template; Advanced
|
|
// carries the same override set as the manual Channel Builder (reuses CreateChannelFromLineupAdvancedOptionsRequest);
|
|
// Logo is an uploaded channel image ({path, contentType}). All optional — an omitted field keeps the PR1
|
|
// behavior (batch template, axis-derived playback order, no logo). Note: no #nullable pragma here (matches the
|
|
// rest of this file), so the new reference-type params carry no `?` annotation; they default to null.
|
|
public record AutoTunedChannelRequest(
|
|
AutoTuneAxis Axis,
|
|
string Value,
|
|
string Name,
|
|
string Number,
|
|
int? TemplateId = null,
|
|
ArtworkContentTypeModel Logo = null,
|
|
CreateChannelFromLineupAdvancedOptionsRequest Advanced = null,
|
|
List<AutoTuneSourceWeightRequest> Sources = null)
|
|
{
|
|
public AutoTuneChannelSelection ToCommand() =>
|
|
new(
|
|
Axis,
|
|
Value,
|
|
Name,
|
|
Number,
|
|
TemplateId,
|
|
(Logo ?? ArtworkContentTypeModel.None).Sanitized(),
|
|
Advanced?.ToCommand(),
|
|
Sources?.Select(s => s.ToCommand()).ToList());
|
|
}
|
|
|
|
// Per-source rotation weight + query correction (#425). SourceId is the show/movie id from the members
|
|
// list (GET /api/v1/channels/auto-tune/members); Weight defaults to 1 (fair-share); Excluded drops it.
|
|
public record AutoTuneSourceWeightRequest(int SourceId, int Weight = 1, bool Excluded = false)
|
|
{
|
|
public AutoTuneSourceWeight ToCommand() => new(SourceId, Weight, Excluded);
|
|
}
|