fix(72): report a real per-channel playout count on the channels API
The channels API could not answer "will this channel play?", which #72 needs to flag a broken channel in the lineup at a glance. Two defects, one root cause each: 1. `ChannelRepository.GetChannel` never included `Playouts`. The read is AsNoTracking with no lazy-loading proxies, so the navigation came back empty and `GetChannelByIdForApiHandler`'s `channel.Playouts?.Count ?? 0` could only ever evaluate to 0 — `GET /api/v1/channels/{id}` reported `playoutCount: 0` for every channel on the system. That silently disabled the channel editor's playout-source guard (ChannelEditScreen:820, gated on `playoutCount > 0`), so the "Cannot be changed once a generated channel has a playout" control was always live. The server still enforces the invariant (UpdateChannelHandler coerces Mirror back to Generated), so nothing was corrupted — but the user's change was silently discarded. That silent coercion is filed separately as #401. 2. The detail path counted only the channel's own playouts, never the mirror source's, so a working Mirror channel would read as "no playout" even once the include landed. Both call sites now share `Mapper.GetPlayoutsCount` (previously private to GetAllChannelsHandler), which handles the Mirror case. `ChannelResponseModel` gains `PlayoutCount` so the list — #72's actual surface — can render it; the count is free there, since `GetAll` already includes `Playouts` and `MirrorSourceChannel.Playouts` and simply discarded them. Tests run the real repository against a real context on purpose: a handler test with a substituted IChannelRepository populates `Playouts` itself, so it passes whether or not the query includes them. Proven non-vacuous — removing the include again turns the 2-playout and mirror cases red (0 CS errors, so no stale-dll false pass). Refs #72
This commit is contained in:
Vendored
+1
@@ -239,6 +239,7 @@ export interface components {
|
||||
"streamingMode": string;
|
||||
"isEnabled": boolean;
|
||||
"showInEpg": boolean;
|
||||
"playoutCount": number;
|
||||
};
|
||||
"ChannelSongVideoMode": "Default" | "WithProgress";
|
||||
"ChannelStateResponseModel": {
|
||||
|
||||
Reference in New Issue
Block a user