`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#690fixes#758
Bug 1 (500 on watermark/graphics save): Replace/Add handlers projected the
freshly-built entity graph, whose ProgramScheduleItemWatermark / -GraphicsElement
join rows carry only foreign-key ids — the Watermark/GraphicsElement navs are null,
and Mapper.ProjectToViewModel dereferences them unguarded, throwing an NRE that the
controller surfaced as a 500 on PUT/POST. Both handlers now reload the persisted
item(s) through the read-side include chain before projecting. Extracted that chain
into ProgramScheduleItemQueryExtensions.IncludeScheduleItemDetails() so GET, Replace
and Add share one source of truth.
Masking: PersistItems returned a lazy LanguageExt Map, and the existing round-trip
test only checked .IsRight — never enumerating it, so the deferred NRE never fired.
The new ScheduleItemWriteProjectionTests force enumeration (as the controller's
.ToList()/serialization does) and seed watermark/graphics via a separate context so
the handler's fresh factory context has nothing pre-tracked.
Bug 2 (server side): GetProgramScheduleItemsHandler now .OrderBy(i => i.Index) —
it previously returned id order, which is not index order.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix validation in new form layout
* pin mediatr to last oss version
* update dependencies
* cleanup code in core
* cleanup code in ffmpeg
* cleanup code in infra
* cleanup code in scanner
* cleanup code in application
* cleanup main code
* cleanup test code
* solution-wide code cleanup
* start to add multi-collections
* create multi collection with no items
* edit multi collections
* fix plex credentials threading issue
* add playback order to multi collection items
* group episodes outside of shuffled enumerator
* move playback order onto each schedule item
* fix multi collection grouping
* update changelog