feat(api): schedule item duration estimates (#111) #118

Merged
timothy merged 3 commits from feat/111-schedule-durations into main 2026-07-04 00:00:33 +02:00
Owner

Endpoint change

GET /api/schedules/{id}/items now returns ProgramScheduleItemsWithDurationViewModel: the items plus per-item durationEstimate and totalDurationEstimate (intentional shape change per #111; nothing on main consumed the old array shape).

Estimate semantics: One → average positive playout duration of the referenced plain collection; Multiple Count → average × count (expression-based counts → null); Multiple CollectionSize → total collection duration; Duration → explicit playoutDuration; Flood / smart / multi / playlist / search references → null (unknown). Aggregation reuses GetDurationForPlayout() semantics incl. the remote-stream fallback.

Implemented by the Codex session; handler/controller tests included; v1.json regenerated (nullable durationEstimate correctly emitted as ["null","string"]).

Adversarial review verdict

Mergeable as-is — no blockers/majors. Minors noted and deferred: Count="0" reports null rather than a knowable 0; per-collection full materialization (fine for an interactive GET, SQL aggregate if this ever gets polled). The one suggested doc fix (expression counts → null) is applied in the follow-up commit.

fixes #111

🤖 Generated with Claude Code

## Endpoint change `GET /api/schedules/{id}/items` now returns `ProgramScheduleItemsWithDurationViewModel`: the items plus per-item `durationEstimate` and `totalDurationEstimate` (intentional shape change per #111; nothing on main consumed the old array shape). Estimate semantics: One → average positive playout duration of the referenced plain collection; Multiple Count → average × count (expression-based counts → null); Multiple CollectionSize → total collection duration; Duration → explicit `playoutDuration`; Flood / smart / multi / playlist / search references → null (unknown). Aggregation reuses `GetDurationForPlayout()` semantics incl. the remote-stream fallback. Implemented by the Codex session; handler/controller tests included; `v1.json` regenerated (nullable `durationEstimate` correctly emitted as `["null","string"]`). ## Adversarial review verdict **Mergeable as-is** — no blockers/majors. Minors noted and deferred: `Count="0"` reports null rather than a knowable 0; per-collection full materialization (fine for an interactive GET, SQL aggregate if this ever gets polled). The one suggested doc fix (expression counts → null) is applied in the follow-up commit. fixes #111 🤖 Generated with [Claude Code](https://claude.com/claude-code)
timothy added 3 commits 2026-07-03 23:36:42 +02:00
Untrusted draft — no build/test had run yet. Review before building on it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
refs #111
docs: note expression-based counts yield null duration estimate
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 3m34s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 4m25s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
63c48f1985
Adversarial review finding on #111: MultipleMode.Count supports
expressions the estimator cannot evaluate; document that they
produce a null (unknown) estimate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
timothy force-pushed feat/111-schedule-durations from 63c48f1985 to 14d06a1e49 2026-07-03 23:43:22 +02:00 Compare
timothy merged commit 43f81d3a49 into main 2026-07-04 00:00:33 +02:00
Sign in to join this conversation.