Repository navigation
fix(sections): rank discovery rows by vote-weighted TMDB rating - #2169
Conversation
Rating-led Home rows (Critically Acclaimed, Hidden Gems, Forgotten Favorites, Short & Sweet, moods) filtered on the IMDb rating, which only optional plugins supply, so they stayed empty on TMDB-only servers. On a large library a raw rating also lets titles rated 10 by one to three people lead every row. - Filter on TMDB and require a minimum TMDB vote count (500 for Critically Acclaimed, 100 elsewhere). The count and average are copied from the item's tmdb rating source onto media_items.tmdb_vote_count and tmdb_vote_average whenever rating sources are written, and rows rank by (votes x average + 500 x 6.5) / (votes + 500) under a matching partial index. - A scheduled refresh now updates rating sources the same provider stored earlier, so counts keep moving after release; it still never overwrites another provider's source. - Each row shows a deterministic daily pick from its best five times its limit, so it changes day to day. - Preset descriptions state the genres, rating floor and vote minimum; the Add row preview shows them when nothing matches, and mood cards use them as hints. - Format showcase, anniversary and seasonal rows sort by the weighted rating too, then by raw TMDB rating for titles without a count. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Keep the TMDB vote pair in step with a trigger on media_item_rating_sources instead of a second statement, so every writer updates it atomically. Backfill in committed batches and drop a leftover index concurrently, so the migrations never hold media_items locked. - A full-chain scheduled refresh overwrites the rating sources it reports; the bulk enrichment pass stays fill-empty. The chain's provider order then decides the tmdb row, so MDBList-owned or orphaned rows update. - Run moods, Short & Sweet and Genre Roulette through the catalog discovery query, which honors the viewer's library allowlist; Genre Roulette gains the vote minimum. Drop the rating_tmdb rule field. - Carry the day in daily-mix cache keys, cap the pool at 250, fall back to created_at for added_at, and add rating_imdb to the unweighted order. - Catalog transfer exports and imports the vote pair. - Web: show a preset's rule only for a row that uses its params, and test that the row list and picker repeat the server's rule text. - List the rating-source Postgres tests in the CI DB contracts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Catalog transfer carries each item's tmdb rating source instead of the derived pair and writes it after every import path, so the trigger derives the pair and an overwritten item without one is cleared. - The vote-pair backfill locks source rows before reading them, so a concurrent clear can't leave a stale count; the trigger skips no-op updates so bulk deletes don't fire media_items statement triggers per row. - Genre Roulette picks from genres among titles with the vote minimum. - Web row text treats zero or negative max_minutes and lookback_days as the server does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughTMDB vote counts and averages now support discovery filtering and weighted ranking. Discovery sections use larger candidate pools and deterministic daily selection. Recipe descriptions and admin previews state the rating, vote, and other criteria used by these rows. ChangesTMDB Discovery Rows
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~60 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant SectionFetcher
participant DiscoveryRepository
participant dailyBestOf
SectionFetcher->>DiscoveryRepository: Query an expanded candidate pool
DiscoveryRepository-->>SectionFetcher: Return matching discovery items
SectionFetcher->>dailyBestOf: Select items for the row limit and UTC day
dailyBestOf-->>SectionFetcher: Return selected items in pool order
Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable issue remains in the supplied review evidence. Normal checks, including the pending database contract tests, should still run before deployment. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)✅ Passed checks (4 passed)Full details: Docstring CoverageExplanation Docstring coverage is 44.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 70 functions across 31 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Rows such as Critically Acclaimed now show only titles enough people rated on TMDB (Silo-Server/silo-server#2169). Say where the counts come from, how to fill them at once, and that the row preview says what an empty row looks for. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
The genre candidates counted every title with the vote minimum, while the row itself also requires movies or series at its rating floor. A row with a high floor could rotate onto a genre that leaves it empty for the whole rotation. The candidates now apply the same filters, and the floor is part of their cache key. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 268e0f1ccd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 788acf6893
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- The vote backfill locks each batch's items and then their sources, skipping rows another transaction holds, so it never waits and cannot deadlock with a content-ID rename or catalog import (item first) or a rating-source write (source first). - Catalog import clears an overwritten item's TMDB source only when the bundle marks that it carries sources, so a bundle from an older exporter no longer wipes them. - Discovery rows treat an explicit empty library scope as no library, as the section fetcher's own scope does. - An empty editorial candidate set is not cached, so Genre Roulette picks up genres once a refresh fills TMDB vote counts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
The TMDB vote trigger updates the item after the source row, while a catalog import holds its items and then writes their sources. A metadata refresh writing the same item's sources could deadlock with the import and abort it. RatingSourceRepository now locks the item first, so every writer takes the item before its sources and they wait for one another. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
The backfill skips items another transaction holds so it never waits. An item held by a writer that does not touch rating sources, such as an artwork update, kept a NULL vote pair until its next refresh. Up to four more passes a second apart now retry such items once their lock is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
SKIP LOCKED avoids waiting on the item and source row locks; the comment no longer claims the backfill can never wait at all. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
…empty # Conflicts: # scripts/ci/db-contracts.txt
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2af0891919
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const preset = | ||
| matched && Object.keys(draft.config).every((key) => key in matched.default_params) | ||
| ? matched |
There was a problem hiding this comment.
Allow legacy acclaimed configs to match the preset
When an existing Critically Acclaimed row was created from the old preset, its saved config contains {"min_score":8,"source":"imdb"}, while this change removes source from the preset and intentionally ignores it in the resolver. This exact-key check therefore rejects every such legacy row, so an empty edit preview never receives description_short and omits the new TMDB vote-count explanation precisely while those rows may be empty awaiting refresh. Normalize the ignored legacy key or otherwise treat it as preset-compatible here.
Useful? React with 👍 / 👎.
The mood, Short & Sweet and Genre Roulette rows moved from the query executor to the discovery repository, which applied library and maturity limits but not the access filter's content allow-list or name prefix. AppendContentScope adds both, matching the query executor, to every discovery query and to Genre Roulette's genre candidates. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
* docs(collections): describe the new Collections page, editor, and profile sharing Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * docs(collections): cover the admin List, Arrange, and starter packs Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * docs(home): describe Admin > Home rows Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * docs(home): update changing your own home rows Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * docs(home): explain rating rows that need TMDB vote counts Rows such as Critically Acclaimed now show only titles enough people rated on TMDB (Silo-Server/silo-server#2169). Say where the counts come from, how to fill them at once, and that the row preview says what an empty row looks for. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(home): call the admin page Sections, as the app does * docs(collections): say a server collection needs a row to show on Home * docs(collections): leave smart collections out of the poster collage * docs(collections): name the starter pack add button plainly * docs(collections): move the empty collection check to its own section * docs(home): say what Restore defaults removes and name its profile switch * docs(home): name the add button when a row goes to several pages * docs(collections): say sharing needs more than one profile * docs(collections): retitle the admin page Create server collections * docs(collections): drop the iPhone and iPad steps for making a collection The app has the create screen, but nothing on iPhone or iPad opens it, and it can't add titles to a collection. --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]> Co-authored-by: zZebrahz <[email protected]>
Problem
Related issue: #1961
Validation tasks: none
The rating-led Home rows that admins add from the gallery (Critically Acclaimed, Hidden
Gems, Forgotten Favorites, Short & Sweet, Genre Roulette and the mood rows) either stay
empty or fill up with titles nobody has heard of.
On a server that uses the TMDB plugin alone, they are empty, while TMDB Trending works.
thousands of titles have a TMDB average of exactly 10.0; those with a recorded vote count have
at most 3 votes. IMDb has the same problem. Whichever rating is used, these titles fill
every row.
This change ranks the rows by TMDB rating weighted by TMDB vote count, requires a minimum
number of votes, shows a different set of top titles each day, and states each preset's
rule in the gallery. It relies on silo.tmdb 1.2.25, which sends TMDB vote counts
(Silo-Server/silo-plugin-metadata-tmdb#24).
Approach
tmdbrating source(feat(metadata): store per-source ratings from metadata plugins #1490). A trigger on
media_item_rating_sourcescopies that row's count and averageonto two new
media_itemscolumns,tmdb_vote_countandtmdb_vote_average, in thesame statement as every write, so the rows can filter and index them without a join.
Since the trigger updates the item after the source, the rating-source repository locks
the item first, the order catalog import and content-ID renames already use, so these
writers wait for one another instead of deadlocking.
The pair always comes from one row.
rating_tmdbisn't used for ranking because ascheduled refresh never overwrites it and it can predate the count. Catalog transfer
carries each item's
tmdbsource, so the trigger derives the pair on import too; abundle from an older exporter, which has no sources, leaves the target's in place.
by
(votes × average + 500 × 6.5) / (votes + 500), under a matching partial index builtconcurrently. A 10.0 from three votes ranks near 6.5; an 8.4 from 20,000 keeps about
8.4. All of these rows now go through the catalog discovery query, which limits them to
the viewer's libraries and the access filter's content allow-list and name prefix; an
explicit empty library list matches nothing. Format showcase, anniversary and seasonal
rows sort by the same value first, then by raw TMDB and IMDb rating for titles with no
count.
chain reports, as a manual refresh does; the chain's provider order picks one entry per
source. Before, a title's first stored score and count never changed until a manual
refresh, so a film first matched in its release week would stay below the vote minimum.
The bulk enrichment pass still only fills missing sources, so MDBList can't replace the
TMDB plugin's row. The
rating_*columns keep their fill-empty rule.and shows a deterministic pick from that pool, keyed by row kind and UTC day. Shared
rows carry the day in their cache key, so every node switches at the same midnight.
Genre Roulette already rotates its genre, so it shows the genre's best titles; it now
picks only from genres that have titles the row can show, and an empty genre list isn't
cached, so the row fills once a refresh brings vote counts.
web Add row dialog shows that text under an empty preview and uses it as the hint on
mood cards. The web row list and picker repeat it, and a test keeps them in step with
the server. Critically Acclaimed's default config drops an unused
"source": "imdb".Existing titles get vote counts on their next refresh. A full library refresh fills them
all at once; until then the rows show only titles that already have a count (on servers
with MDBList, the titles it enriched).
The API is unchanged apart from
description_shorttext in the recipe catalog, whichApple and Android don't read. Jellycompat doesn't serve these rows; it uses the section
fetcher only for Latest and Resume.
The design doc is
docs/architecture/discovery-row-ranking.md.Validation
gofmt,go vetandmake lint-changedpass.make test-gopasses exceptTestRunStatsWithRealFFmpeg, which fails the same way on main with the local ffmpeg.make test-webpass.verify-*targets in the contributing gate,migrate-validateand the router artifact test pass.
runtime filters and weighted order in the queries, the Go expression matching the index
migration, the refresh and enrichment write modes, preset descriptions, the
empty-preview text, and the web text matching the server's.
to the CI DB contracts list. They need Silo's full schema and did not run locally.
the batched backfill, every trigger path (insert, update, NULL votes, delete, both
upsert conflict modes, content-ID rename and item delete cascades), the index build, a
rerun and Down/Up. The backfill also ran while seven sessions held locks (a content-ID
rename, a source cleared, a source set, a rolled-back clear, an item-only update and a
new source for 2 s; another item update for 15 s). It finished in 6.2 s with no errors,
every filled pair matched its source, and only the item held for 15 s stayed unfilled.
An import-style transaction holding an item while a refresh upserted its
tmdbsourcedeadlocked with the old lock order; with the item locked first, the refresh waited and
then applied its values. Both query shapes used
the new index with bind parameters (about 0.3 ms for 100 rows). The catalog import's
rating-source statements ran there too (create, overwrite with and without a source).
the new ranking puts well-known, well-rated titles first.
full refresh with TMDB vote counts.
Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/discovery-ranking/
Risks
fewer titles, or none on a server without MDBList. The Add row preview says what each
row needs. Ship the plugin before this server change.
which adds writes on libraries that refresh often.
batches, and builds the index concurrently. The backfill skips rows another transaction
holds rather than wait on them and retries them in up to four more passes a second
apart; an item held longer than that gets its pair from its next refresh.
Follow-ups
rating_*columns still keep only their first value on a scheduled refresh, so a title page can show an older TMDB score than the one these rows rank by.Checklist
AI Disclosure
sonnetalias (two review subagents); gpt-6.1-sol (review)finders, a validation agent and a sweep; candidates were checked against the source by
the lead agent rather than separate verifiers) and two rounds with Codex gpt-6.1-sol.
Round one found a backfill holding
media_itemslocked, the moved mood query skippingthe library allowlist, MDBList-owned
tmdbrows that a refresh could never update, avote copy outside the source write, a blocking invalid-index cleanup, catalog transfer
dropping counts, a cache key without the day, an oversized pool, a lost
added_at, awidened query vocabulary and preset text shown for customized rows. Round two found
import paths that still dropped counts, a backfill race with a concurrent clear,
Genre Roulette choosing genres with no voted titles, no-op trigger updates on bulk
deletes and web defaults for zero settings. On the open PR, Kody found Genre Roulette
choosing genres the row's rating floor would empty and the backfill not retrying items
it skipped, and Codex found the backfill's lock
order could deadlock with a content-ID rename, a refresh's source write could deadlock
with a catalog import, older catalog bundles clearing sources,
explicit empty library scopes showing every library, and an empty genre list cached
for a day. Codex also found that discovery rows ignored the access filter's content
allow-list and name prefix. All are fixed. Left as they are: Genre
Roulette has no daily pick (it rotates weekly); a refresh that reports a source
without a count clears the count, as a manual refresh already does; the rows stay
sparse until refreshes fill counts (see Risks); the
rating_*columns keep theirfill-empty rule.
🤖 Generated with Claude Code
Note
Rank discovery rows by vote-weighted TMDB rating with daily mixing
tmdb_vote_count/tmdb_vote_averagecolumns and a synchronization trigger onmedia_item_rating_sources(migrations 20261008200122 and 20261008200123)FOR NO KEY UPDATEin rating_source_repo.go; manual and scheduled refreshes overwrite reported sources, while enrichment only fills missing onesTMDBRatingSourcesmanifest flag in types.gorecipes.CriticallyAcclaimedParamsdrops theSourcefield and its default JSON no longer includessource; the backfill migration runs batched with row locks and up to five passesMacroscope summarized 7d91815.