Backend: schedule item duration estimates + schedule total #111

Closed
opened 2026-07-02 19:44:04 +02:00 by timothy · 2 comments
Owner

From the ChicoryTV plan audit (epic #59, 2026-07-02).

The Schedule editor prototype renders a per-item duration chip (durEst) and a header total ("programs ~3h 46m") — but GET /api/schedules/{id}/items returns settings (e.g. PlayoutDuration), not computed runtime estimates; Flood/One/Multiple items have no runtime at all.

Scope

  • Add a computed runtime estimate per item and a schedule total to the items response (or a sibling /items/durations), derived from the referenced collection/media durations.
  • Regenerate OpenAPI + SPA types.

Non-blocking for #86 (chips + header summary only; the editor works without them). Effort: M.

From the ChicoryTV plan audit (epic #59, 2026-07-02). The Schedule editor prototype renders a per-item duration chip (`durEst`) and a header total ("programs ~3h 46m") — but `GET /api/schedules/{id}/items` returns *settings* (e.g. `PlayoutDuration`), not computed runtime estimates; Flood/One/Multiple items have no runtime at all. **Scope** - Add a computed runtime estimate per item and a schedule total to the items response (or a sibling `/items/durations`), derived from the referenced collection/media durations. - Regenerate OpenAPI + SPA types. Non-blocking for #86 (chips + header summary only; the editor works without them). Effort: M.
timothy added the enhancementapi labels 2026-07-02 19:44:04 +02:00
Author
Owner

Implementation (by the Codex session) is complete and has passed a fable adversarial review: mergeable as-is, no blockers/majors. Verified: duration math reuses GetDurationForPlayout() semantics incl. remote-stream fallback; no divide-by-zero; OpenAPI nullability typegen-safe; 404 contract preserved; tests behavioral.

Minors noted, deferred: expression-based Count values yield a null estimate (now documented in the XML doc — follow-up commit 63c48f19); Count="0" reports null rather than 0; per-collection full materialization acceptable for an interactive GET.

PR #118 opened against main. It regenerates v1.json and will be rebased/regenerated after PR #117 (#104 artwork upload) merges, since both touch the spec.

Implementation (by the Codex session) is complete and has passed a fable adversarial review: **mergeable as-is**, no blockers/majors. Verified: duration math reuses `GetDurationForPlayout()` semantics incl. remote-stream fallback; no divide-by-zero; OpenAPI nullability typegen-safe; 404 contract preserved; tests behavioral. Minors noted, deferred: expression-based `Count` values yield a null estimate (now documented in the XML doc — follow-up commit 63c48f19); `Count="0"` reports null rather than 0; per-collection full materialization acceptable for an interactive GET. PR #118 opened against main. It regenerates `v1.json` and will be rebased/regenerated after PR #117 (#104 artwork upload) merges, since both touch the spec.
Author
Owner

Closing summary (merged via PR #118)

What was done: GET /api/schedules/{id}/items now returns ProgramScheduleItemsWithDurationViewModel — the items plus per-item durationEstimate and totalDurationEstimate. Semantics: One → average positive playout duration of the referenced plain collection; Multiple Count → average × count (expression-based counts → null, documented); Multiple CollectionSize → total collection duration; Duration → explicit playoutDuration; Flood and smart/multi/playlist/search references → null (unknown). Aggregation reuses GetDurationForPlayout() semantics incl. remote-stream fallback. Intentional response-shape change; Blazor UI unaffected (uses the untouched GetProgramScheduleItems query).

Files changed: new GetProgramScheduleItemsWithDurations{,Handler}.cs, ScheduleItemDurationEstimator.cs, ProgramScheduleItemsWithDurationViewModel.cs, DurationEstimate on ProgramScheduleItemViewModel, ScheduleController.GetItems swap, handler + controller tests, regenerated v1.json.

Review: fable adversarial review verdict mergeable as-is; suggested doc fix applied. Deferred minors: Count="0" reports null rather than a knowable 0; per-collection full materialization (fine for interactive use, SQL aggregate if polled).

Docs: none needed beyond OpenAPI; no operational behavior change.

Implemented by the Codex session; reviewed, finished, and merged by the Claude session.

## Closing summary (merged via PR #118) **What was done**: `GET /api/schedules/{id}/items` now returns `ProgramScheduleItemsWithDurationViewModel` — the items plus per-item `durationEstimate` and `totalDurationEstimate`. Semantics: One → average positive playout duration of the referenced plain collection; Multiple Count → average × count (expression-based counts → null, documented); Multiple CollectionSize → total collection duration; Duration → explicit `playoutDuration`; Flood and smart/multi/playlist/search references → null (unknown). Aggregation reuses `GetDurationForPlayout()` semantics incl. remote-stream fallback. Intentional response-shape change; Blazor UI unaffected (uses the untouched `GetProgramScheduleItems` query). **Files changed**: new `GetProgramScheduleItemsWithDurations{,Handler}.cs`, `ScheduleItemDurationEstimator.cs`, `ProgramScheduleItemsWithDurationViewModel.cs`, `DurationEstimate` on `ProgramScheduleItemViewModel`, `ScheduleController.GetItems` swap, handler + controller tests, regenerated `v1.json`. **Review**: fable adversarial review verdict mergeable as-is; suggested doc fix applied. Deferred minors: `Count="0"` reports null rather than a knowable 0; per-collection full materialization (fine for interactive use, SQL aggregate if polled). **Docs**: none needed beyond OpenAPI; no operational behavior change. Implemented by the Codex session; reviewed, finished, and merged by the Claude session.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#111