fix(api): surface programs not filler in channel state, tighten queries
Adversarial review fixes for the #97 endpoint: - nowPlaying now resolves like the XMLTV guide: when the wall-clock item is pre/mid-roll filler, surface the guide group's program item (title + full program bounds) instead of the filler; a guide entry with no program item (e.g. fallback loop) reports null. Previously an ad break would retitle the channel and reset progress every 30 seconds. - covering-item lookup now runs one cheap projected query per distinct playout offset instead of hydrating the full metadata include tree for a window widened by the largest offset across ALL channels (up to 24h); metadata is fetched in a second query scoped to the covering guide groups, time-bounded to stay safe against GuideGroup recycling (mod 10000). Regression caught while testing: covering items are keyed by (source channel, lookup time) so a source channel no longer inherits its offset mirror's lookup result. - GetChannelStatesForApi now carries Now explicitly (controller passes DateTime.UtcNow), making boundary semantics testable: new tests pin now == Start (playing) and now == Finish (not playing), plus mid-roll, filler-only, and mirror-source-row cases. - ChannelNowPlayingResponseModel title is non-nullable in the schema (#nullable enable) — GetDisplayTitle always returns a string. - GetState uses the typed-return controller convention; Playouts.Mapper reverted to internal (handler lives in the same assembly). - Spec doc notes the OnDemand drift caveat and filler semantics. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,13 +25,8 @@ public class ChannelController(ChannelWriter<IBackgroundServiceRequest> workerCh
|
||||
[Tags("Channels")]
|
||||
[EndpointSummary("Get channel runtime state")]
|
||||
[EndpointGroupName("general")]
|
||||
[ProducesResponseType(typeof(List<ChannelStateResponseModel>), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> GetState(CancellationToken cancellationToken)
|
||||
{
|
||||
List<ChannelStateResponseModel> result =
|
||||
await mediator.Send(new GetChannelStatesForApi(), cancellationToken);
|
||||
return new OkObjectResult(result);
|
||||
}
|
||||
public async Task<List<ChannelStateResponseModel>> GetState(CancellationToken cancellationToken) =>
|
||||
await mediator.Send(new GetChannelStatesForApi(DateTime.UtcNow), cancellationToken);
|
||||
|
||||
[HttpGet("/api/channels/{id:int}", Name = "GetChannelById")]
|
||||
[Tags("Channels")]
|
||||
|
||||
Reference in New Issue
Block a user