Commit Graph
2 Commits
Author SHA1 Message Date
timothy b0c1f8b51e fix(690,758): answer cold review — derive the population by shape, not by name
Round 1 of the cold adversarial review found no correctness defect in the six
handler fixes, and three real defects in what the change CLAIMED. Answering
them here rather than in the doc, per docs.no-session-narrative.

1. The record said the population was "eight `GetPaged*Handler` types, fully
   enumerated". That is a NAME-derived population — the exact method the record
   itself condemns two paragraphs earlier. Deriving it by SHAPE from the git
   index (CountAsync / .Skip( / TotalCount) finds three more count+page
   producers in ErsatzTV.Application/MediaCards with the same drift:
   GetTelevisionSeasonCards (counts ShowId == showId, pages every show sharing
   a Title+Year), GetTelevisionEpisodeCards and GetMusicVideoCards (count the
   item table, page the metadata table). All three are unreachable dead code
   left by blazor.ui-removed — zero call sites outside their own Queries folder
   — and page 1-based against api.paging-zero-based, so they are DEFERRED to
   #832 and recorded, not folded in. An unrecorded site reads as a clean tree.

2. docs/api-conventions.md was not updated. CLAUDE.md's docs table makes that a
   same-PR hard rule, and its "Paged GET with clamped params" exemplar is where
   a controller author actually looks. It now carries the count rule.

3. The `Channel != null` claim was a mechanism I did not measure. Playout.ChannelId
   is non-nullable with DeleteBehavior.Cascade and both production connection
   strings set foreign keys=true, so the orphan state is unreachable while the FK
   holds. The clause is defensive; the record no longer describes an inflated
   total anyone saw. Same correction for blast radius: only rerun-collections,
   multi-collections and playouts reach a controller — the other three had no
   production caller and were latent, not live.

Also: GetPagedFillerPresets and GetPagedTraktLists now derive count and page
from one query too. Their DbSet counts were not wrong (they take no Query
parameter), but leaving them counting one expression while paging another
preserves the drift for whoever adds the first filter — which is the argument
the record makes, so exempting them contradicted it.

And a test that pins the property the issues are actually about: pageSize 1
over 2 matching rows, asserting a real second page and an empty page past the
last match. Every previous case fit on one page, so none exercised the count
driving pagination at all.

refs #832
2026-08-26 08:23:07 +02:00
timothy 19bb605aae fix(690,758): count the same query a paged handler pages
`GetPagedRerunCollections` (#690) and `GetPagedPlayouts` (#758) were filed as
separate bugs; they are one mechanism, and the sweep found it at six sites.
Each handler computed `CountAsync` over the whole `DbSet` and then paged a
differently-filtered `IQueryable`, so `TotalCount` reported the size of the
table whenever a search query was supplied. The page is right and the count is
wrong, which is silent: the SPA paginates on `TotalCount` and renders pages
that can never contain anything, and an MCP agent paging to a completeness
target reads a total its own page can never reach.

The two named handlers were two of six. Sweeping `ErsatzTV.Application` for the
shape rather than auditing the issues' file lists also found
`GetPagedCollections`, `GetPagedMultiCollections`, `GetPagedSmartCollections`
and `GetPagedProgramSchedules`. `GetPagedMultiCollections` and
`GetPagedSmartCollections` were in the half-state that makes the structural fix
the right one: their counts carried the `OwnedByChannelId == null` clause
faithfully and silently omitted the `Query` clause added later.

So the fix is not "add the missing Where to the count" — both are derived from
one `IQueryable` and cannot drift. Includes move to the page chain, where they
already belonged: a COUNT does not materialize the graph, and #671's bound on
the rerun selection graph is unaffected. `GetPagedPlayouts` additionally gains
its `Channel != null` filter in the count, which the DbSet count never had.

`GetPagedFillerPresets` and `GetPagedTraktLists` take no `Query` parameter, so
their DbSet counts already count what they page and are deliberately unchanged.
`GetBlockPlayoutHistory`, `GetFuturePlayoutItemsById` and `GetLibraryBrowseItems`
already used this idiom.

Mutation proof: restoring the pre-fix `CountAsync` clause at all six sites turns
all six new tests red; each test constructs exactly one handler, so every test
is shown to detect its own site. Expected counts are pinned literals, never
recomputed by re-applying the handler's own predicate.

BOMs stripped from the three touched handlers that carried one (#311
fix-as-you-touch; `dotnet format whitespace` reported CHARSET on them).

fixes #690
fixes #758
2026-08-26 08:04:03 +02:00