Repository navigation
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e837c79f5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| defer cancel() | ||
|
|
||
| foundRT := false | ||
| defer func() { b.release(contentID, foundRT) }() |
There was a problem hiding this comment.
Retry after transient RT backfill failures
When RatingsByIMDB returns a transient error (429/network) or UpdateMetadata fails, this deferred release still runs with foundRT == false; release treats that exactly like a successful “no RT score” lookup and negative-caches the title for 24 hours. In those failure cases the next item view cannot retry the backfill until the TTL expires, so only successful lookups with no RT data should populate the negative cache.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — fixed in 49ba11a. run() now negative-caches only when a successful lookup genuinely returns no RT score; transient failures (RatingsByIMDB error like 429/network, or UpdateMetadata error) release without caching, so the next item view retries instead of being skipped for the 24h TTL. Added tests TestRTBackfillFetchErrorDoesNotNegativeCache and TestRTBackfillPersistErrorDoesNotNegativeCache covering both paths.
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR adds MDBList Rotten Tomatoes rating lookup, wires shared ratings/backfill dependencies through startup and routers, enriches metadata refreshes with RT scores, and propagates RT critic ratings through Jellyfin compatibility mappings and item-detail handling. ChangesRotten Tomatoes ratings flow
Estimated code review effort: 4 (Complex) | ~60 minutes Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
49ba11a to
5eaec62
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/silo/main.go (1)
1826-1839: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winRT backfill/ratings-fetcher wiring is gated on an unrelated dependency (
UserStoreProvider).
metadataService.SetRatingsFetcher(...)anddeps.RTBackfiller = rtbackfill.New(...)only run insideif deps.UserStoreProvider != nil, a block whose actual purpose is wiring up user-collection sync. IfUserStoreProvideris nil (e.g. a deployment mode whereneedsUserDBis false, or user store init fails) butDB/metadataServiceare available, both the metadata-refresh RT enrichment and the on-view RT backfiller silently never get created — with no log/warning that the RT feature is disabled. Neither feature has any actual dependency on the user store.Consider hoisting the
SetRatingsFetcher/RTBackfillerconstruction out of theUserStoreProviderconditional (e.g. gate solely ondeps.MDBListClient != nilandmetadataService != nil), so the feature's availability tracks its real dependencies.♻️ Proposed restructuring
- if deps.UserStoreProvider != nil { - userSync := usercollections.NewService(deps.UserStoreProvider, collItemRepo, libraryItemRepo, nil, slog.Default()) - userSync.TMDBCollections = collectionService.TMDBCollections - // Trakt fetchers are wired in router.go (they need settingsRepo); - // router.go propagates them onto userSync once configured. - userCollectionScheduler = usercollections.NewScheduler(deps.DB, userSync, slog.Default()) - deps.UserCollectionSync = userSync - deps.UserCollectionScheduler = userCollectionScheduler - deps.MDBListClient = mdblist.NewClient(cfg.MDBListAPIKey, nil) - mdblistForReload := deps.MDBListClient - configWatcher.OnChange(func(_, updated *config.Config) { - mdblistForReload.SetAPIKey(updated.MDBListAPIKey) - }) - // Feed Rotten Tomatoes scores from MDBList into metadata refreshes. - if metadataService != nil { - metadataService.SetRatingsFetcher(deps.MDBListClient) - } - // One shared on-view RT backfiller for both the native item detail - // handler and the Jellyfin compat surface (single in-flight/negative - // cache). - deps.RTBackfiller = rtbackfill.New(deps.MDBListClient, catalog.NewItemRepository(deps.DB)) - } + deps.MDBListClient = mdblist.NewClient(cfg.MDBListAPIKey, nil) + mdblistForReload := deps.MDBListClient + configWatcher.OnChange(func(_, updated *config.Config) { + mdblistForReload.SetAPIKey(updated.MDBListAPIKey) + }) + // Feed Rotten Tomatoes scores from MDBList into metadata refreshes. + if metadataService != nil { + metadataService.SetRatingsFetcher(deps.MDBListClient) + } + // One shared on-view RT backfiller for both the native item detail + // handler and the Jellyfin compat surface (single in-flight/negative + // cache). + deps.RTBackfiller = rtbackfill.New(deps.MDBListClient, catalog.NewItemRepository(deps.DB)) + if deps.UserStoreProvider != nil { + userSync := usercollections.NewService(deps.UserStoreProvider, collItemRepo, libraryItemRepo, nil, slog.Default()) + userSync.TMDBCollections = collectionService.TMDBCollections + userCollectionScheduler = usercollections.NewScheduler(deps.DB, userSync, slog.Default()) + deps.UserCollectionSync = userSync + deps.UserCollectionScheduler = userCollectionScheduler + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/silo/main.go` around lines 1826 - 1839, The RT ratings/backfill setup is incorrectly tied to the UserStoreProvider branch, so metadataService.SetRatingsFetcher and deps.RTBackfiller can be skipped even when their real dependencies are available. Move the MDBList/RT wiring out of the UserStoreProvider-specific block in cmd/silo/main.go and gate it only on deps.MDBListClient and metadataService (and the DB-backed repository for rtbackfill.New), using the existing symbols metadataService.SetRatingsFetcher, rtbackfill.New, and deps.RTBackfiller so the feature initializes whenever it should.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@cmd/silo/main.go`:
- Around line 1826-1839: The RT ratings/backfill setup is incorrectly tied to
the UserStoreProvider branch, so metadataService.SetRatingsFetcher and
deps.RTBackfiller can be skipped even when their real dependencies are
available. Move the MDBList/RT wiring out of the UserStoreProvider-specific
block in cmd/silo/main.go and gate it only on deps.MDBListClient and
metadataService (and the DB-backed repository for rtbackfill.New), using the
existing symbols metadataService.SetRatingsFetcher, rtbackfill.New, and
deps.RTBackfiller so the feature initializes whenever it should.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 00f1e8e2-da44-41da-83fa-fa2811ee7ce0
📒 Files selected for processing (13)
cmd/silo/main.gointernal/api/handlers/items.gointernal/api/router.gointernal/jellycompat/content_direct.gointernal/jellycompat/handlers_items.gointernal/jellycompat/mapping.gointernal/jellycompat/router.gointernal/jellycompat/server.gointernal/jellycompat/upstream_types.gointernal/mdblist/discovery.gointernal/mdblist/ratings.gointernal/mdblist/ratings_test.gointernal/metadata/service.go
💤 Files with no reviewable changes (10)
- internal/jellycompat/router.go
- internal/jellycompat/server.go
- internal/jellycompat/upstream_types.go
- internal/mdblist/ratings.go
- internal/mdblist/ratings_test.go
- internal/jellycompat/content_direct.go
- internal/mdblist/discovery.go
- internal/jellycompat/mapping.go
- internal/jellycompat/handlers_items.go
- internal/metadata/service.go
Add mdblist.RatingsByIMDB to fetch the RT tomatometer/audience score by IMDb id, and enrich metadata refreshes with it via a nil-safe RatingsFetcher injected into the metadata service. Best-effort: lookup failures are logged and never fail a refresh, and a plugin-provided RT score is not clobbered. Fills the previously-scaffolded rating_rt_critic / rating_rt_audience columns that had no populating source. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Jellyfin's CriticRating field is a 0-100 tomato-scored value; it was being fed from TMDB's 0-10 community score. Source it from the real RT tomatometer (RatingRTCritic) instead, threading the field through the upstreamListItem/upstreamItemDetail structs and their constructors. Co-Authored-By: Claude Opus 4.8 <[email protected]>
When a movie or series detail is opened without an RT score, enqueue an async MDBList lookup that upserts rating_rt_critic/audience, so the value appears on the next load. In-flight dedupe and a 24h negative cache keep it from hammering MDBList for titles it has no RT for. Only spends API calls on titles users actually open. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…fallback RatingsByIMDB hit https://api.mdblist.com/?apikey=&i=<imdb>, which returns MDBList's homepage index (params ignored, no ratings array). Every lookup therefore parsed an empty ratings list, so RTCritic was always nil: 0 of ~195k movies/series ever got a Rotten Tomatoes score, and the on-view backfill silently negative-cached each item with no error log. Point RatingsByIMDB at the legacy lookup host https://mdblist.com/api/?i=, which returns the full ratings array with the "tomatoes"/"tomatoesaudience" source names the parser already expects (the REST host renames audience to "popcorn", so it is deliberately not used). Added a dedicated ratingsBaseURL field so discovery keeps using api.mdblist.com. Also restore the pre-branch behavior for Jellyfin CriticRating: prefer the RT critic score when present, else fall back to RatingTMDB. Without this, mapping CriticRating solely from the (until-now always-nil) RT score blanked out ratings for every title in Jellyfin clients. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ller The on-view Rotten Tomatoes backfill was only wired into the native catalog item-detail handler, so opening a title in a Jellyfin/Emby client never populated RT scores. Extract the backfiller into internal/rtbackfill (single implementation, no duplicated logic) and share one instance — with one in-flight/negative cache — between the native surface and jellycompat. - internal/rtbackfill: new package holding the Backfiller moved out of api/handlers (exported New/Enqueue; Fetcher/Updater interfaces). - jellycompat: carry imdb_id through upstreamItemDetail so the handler has the key; enqueue a backfill from HandleItem for RT-less movies/series. - Build the shared backfiller once in main and inject via both api and jellycompat Dependencies. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…al/rtbackfill The on-view backfiller moved to internal/rtbackfill (shared by the native and jellycompat surfaces); these files were the pre-extraction copy left behind in the cherry-pick. Removing the dead duplicate. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ient errors Per Codex review: run() released with foundRT=false on both transient failures (RatingsByIMDB error, UpdateMetadata error) and genuine no-RT results, so a 429/network/DB blip negative-cached the title for 24h and blocked retry on the next view. Negative-cache only when a successful lookup returns no RT score; errors now leave the item retryable. Adds tests for both error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
5eaec62 to
83623de
Compare
|
Thanks for the work on this. We reviewed the exact head This branch combines several independently reviewable concerns—MDBList title-rating transport, metadata-refresh enrichment, native on-view backfill, and Jellyfin compatibility behavior—while Silo follows a one-concern-per-PR policy. The branch is also substantially behind The review surfaced useful requirements around credential-safe errors, MDBList quota control, rating locks and stale-write fencing, independent critic/audience handling, and Jellyfin rating scales. We have preserved that work in focused issues: #692, #693, #694, #695, and #696. Closing this PR in favor of those scoped issues and fresh PRs. This is not a rejection of the feature; it is a request to land it in smaller, independently verifiable pieces. Thank you for establishing the original implementation and live-validation context. |
Problem
Rotten Tomatoes scores were not reaching clients:
RatingsByIMDBrequestedhttps://api.mdblist.com/?apikey=…&i=<imdb>, which returns MDBList's homepage index (params ignored, noratingsarray). Every lookup parsed an empty list, soRTCriticwas always nil — 0 of ~195k movies/series ever received an RT score, and the on-view backfill silently negative-cached each item with no error log.CriticRatingsolely from the (always-nil) RT score removed the previously-shown TMDB value, so clients displayed no critic rating at all./catalog/items/{id}handler, so opening a title in a Jellyfin/Emby client never populated RT.Changes
fix(mdblist)— pointRatingsByIMDBat the legacy lookup hosthttps://mdblist.com/api/?i=, which returns the full ratings array with thetomatoes/tomatoesaudiencesource names the parser expects. (The REST host renames the audience source topopcorn, so it is deliberately not used.) A dedicatedratingsBaseURLkeeps discovery onapi.mdblist.com.CriticRatingprefers the RT critic score when present, else falls back toRatingTMDB, so ratings show immediately and RT overrides as it backfills.feat(jellycompat)— extract the on-view backfiller intointernal/rtbackfill(single implementation, one shared in-flight/negative cache) and trigger it from the Jellyfin item-detail handler as well; carryimdb_idthroughupstreamItemDetailso the handler has the key.Testing
go build ./...,go vet, and package tests pass:internal/mdblist,internal/rtbackfill,internal/jellycompat,internal/api/handlers.movie-tmdb-687163→rating_rt_critic=94, rating_rt_audience=95, matching RT). Confirmed the old endpoint returned only the homepage index.Risks / follow-up
rtbackfillin-flight/negative caches are in-memory and cleared on restart.Scope
No existing Rotten Tomatoes / ratings capability issue was found to link — please advise the correct
Part of #NNNepic to reference.AI use
Implemented with assistance from Claude Code (Opus 4.8). All changes reviewed, built, and verified against a live instance before submission.
Summary by CodeRabbit
New Features
Bug Fixes