A document is one playlist item; its pages are sub-entries, not separate media items #304
Labels
No labels
Area/Backend
Area/Database
Area/Docs
Area/Frontend
Area/Infra
Area/Security
Area/Tests
Area/Tooling
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Lang/Python
Lang/Rust
Lang/Shell
Lang/SQL
Lang/TypeScript
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Routing
Auto
Routing
Hold
Routing
Human
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage#304
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Product owner, 2026-11-17 (GRI-2051): "A document gets a MediaId but pages only a sub ID. Because if somebody pushes all pages, they are multiple objects (like in the 'ingrid' playlist)."
Today. Each page of a PDF/PPTX is its own media row (
kind = document_page,document_id,page, migration 0004). The library picker (#208/#222) has two buttons: Add whole document makes one playlist item, Add N pages makes N separate playlist items, one per page. On the campus test server the playlist "ingrid" has 35 items with 35 different media ids: one document, added page by page. Those 35 rows cannot be timed together, moved together or removed together, and the #278 sub-list cannot group them.Change. A document is always one playlist item, referenced by the document's media id. Its pages are sub-entries of that item, identified by
(document media id, page number)— the "sub id". No playlist item refers to a page's own media id any more.1-5,8-9) adds one document item with only those pages on. The other pages are off ("Skip this page", which already exists in0007_document_page_overrides). Add whole document stays as it is.PUT /playlists/{id}/itemsrefuses adocument_pageitem (422 with a clear message) after the migration. The client protocol already plays a document item page by page, so the player needs no change — check it.Done when: on the test server, "ingrid" shows as one document item with its pages under it, the screen plays the same pages in the same order as before, and adding pages 1-5,8-9 of a deck makes one item.
Works together with #278 (the page sub-list in the playlist). #278 is the screen; this is the data under it.
Backend half in progress on
feature/GRI-2179-document-playlist-item(branched fromdevatd1a9bcb).Scope. This covers the backend only (migration, store, API) — the picker's "Add N pages" button is
frontend-weband is not part of this change; flagging separately below so it can be routed.What's done so far:
crates/server/migrations/0014_consolidate_document_page_items.sql: for every playlist, collapses each maximal run of consecutivedocument_pageitems referencing the same document into onedocumentitem (kept row = the run's first item, so its id/position/validity do not move). A page in the run keeps its ownduration_secondsas a{"seconds": n}override; every other page of that document gets{"skip": true}. Two runs of the same document separated by another item stay two separatedocumentitems — play order never moves. After the conversion, the migration tightensplaylist_items's ownCHECKconstraints so the DB itself can no longer hold adocument_pagerow, not just the API.PUT /playlists/{id}/itemsnow refuses adocument_pageitem with422 document_page_not_allowed(previously it resolved the page number and accepted it). Fixed a bug on the way: the per-item validation error wrapper (ValidationError::at_index) was forcing every validation failure to400, which would have silently downgraded this422— it now keeps the original status.media_integration.rsalready uses for0004's backfill) — the "ingrid" shape (35 consecutive pages, one with its own duration) and an interleaved shape (two runs of the same document split by another item). Plus a unit test and an integration test for the new422refusal.document→ onedocument_pagewire item per page) already existed from GRI-1961/#157 and needed no change — confirmed the client protocol needs nothing here either, per the issue's "check it".Needs a decision from the CTO:
prismancer/glamourweaver's half? This board/forge issue is labelledArea/Backendonly, so I've treated the frontend picker change as out of scope for me — please route it if it needs its own ticket.aetherforge's open branchfix/GRI-2180-pg18-restrict-violation-codealso touchescrates/server/src/playlists/handlers.rs(movingis_foreign_key_violationintocrate::db). My diff doesn't touch that function or its call site, so I don't expect a real conflict, but flagging per the file-ownership rule.Running the local gates now; will report the result and open the PR once green.
PR #312 CI's cargo test failure was a stale test fixture, not the migration:
deleting_a_document_used_by_a_playlist_names_it_and_can_detach_and_deleteinserted its playlist item directly as kind='document_page', which migration 0014's new CHECK now refuses. Fixed the fixture to insert kind='document' against the document's own media id. Verified locally: full media_integration suite 24/24 passed, fmt/clippy clean. Pushed as08b1941; CI re-running.PR #312 CI's cargo test failure was a real bug, not a stale fixture: the 0014 test helper (
reopen_document_page_items) and the backfill-conversion SQL ran a multi-statement string throughsqlx::query(...)(prepared-statement/extended protocol), which Postgres refuses for more than one command (42601). Switched those three call sites tosqlx::raw_sql, which uses the simple protocol — the same mechanismsqlx::migrate!itself uses to run migration files with multiple statements. Verified locally: both 0014-backfill tests (35-consecutive-pages and interleaved shapes) pass, full playlist_integration (42) and media_integration (24) suites pass, fmt/clippy clean. Pushede705af3.Backend PR #312 is reviewed and green; held until the frontend half #314 is green, then both merge together. Detail on #312.