Repository navigation
fix(history-import): import Emby favorites - #378
Conversation
📝 WalkthroughWalkthroughEmby history imports now fetch and merge movie and series favorites, match series with optional TMDb preference, persist favorite-only records without progress or history, track imported favorite counts, and display those counts in the web UI. ChangesEmby favorites import
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant EmbyProvider
participant EmbyClient
participant Matcher
participant Service
participant UserStore
participant WebUI
EmbyProvider->>EmbyClient: Fetch favorite movies and series
EmbyClient-->>EmbyProvider: Favorite items
EmbyProvider->>Matcher: Match merged favorite records
Matcher-->>Service: Matched records
Service->>UserStore: AddFavoriteAt
UserStore-->>Service: Inserted flag
Service-->>WebUI: Run metrics including favorites_imported
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68fcf89bf8
ℹ️ 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.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@internal/historyimport/emby_provider_test.go`:
- Around line 66-73: Add PreferTMDB assertions to the merged movie and series
checks in the favorites test, requiring the flag to be true for both records
while preserving the existing favorite and kind validations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 7ecaedd1-3193-4465-83a1-ffcbc9bf2f43
📒 Files selected for processing (15)
internal/historyimport/emby_client.gointernal/historyimport/emby_favorites_test.gointernal/historyimport/emby_provider.gointernal/historyimport/emby_provider_test.gointernal/historyimport/matcher.gointernal/historyimport/matcher_test.gointernal/historyimport/plex_watchlist_test.gointernal/historyimport/repo.gointernal/historyimport/repo_admin.gointernal/historyimport/service.gointernal/historyimport/types.gomigrations/sql/20260711114310_history_import_favorites_imported.sqlweb/src/api/types.tsweb/src/pages/AdminHistoryImport.tsxweb/src/pages/settings/HistoryImportSettings.tsx
|
Addressed both automated review findings in
Verification: |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
internal/notifications/interest_hooks.go (1)
110-116: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueThis change elegantly avoids redundant interest queue mutations when a favorite already exists. However,
AddFavorite(defined just above) still unconditionally queues mutations because it doesn't know if an insertion occurred.Consider delegating
AddFavoritetoAddFavoriteAtso it shares this deduplication logic:func (s *interestTrackingStore) AddFavorite(ctx context.Context, profileID, mediaItemID string) error { _, err := s.AddFavoriteAt(ctx, profileID, mediaItemID, time.Now().UTC()) return err }internal/userstore/pgstore/favorites.go (1)
18-32: 🧹 Nitpick | 🔵 Trivial
🤖 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 `@internal/notifications/interest_hooks.go`:
- Around line 110-116: Update interestTrackingStore.AddFavorite to delegate to
AddFavoriteAt using the current UTC time, return only the delegated error, and
remove its separate mutation-queue logic so favorite additions share the
inserted-only behavior implemented by AddFavoriteAt.
In `@internal/userstore/pgstore/favorites.go`:
- Around line 18-32: Update interestTrackingStore.AddFavorite to delegate to
AddFavoriteAt using the current timestamp, then return its error. This ensures
QueueItemMutation is triggered only when AddFavoriteAt reports that a new
favorite was inserted, matching the existing AddFavoriteAt behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3c3eaccd-a98b-48e8-852a-56bbe2fa4b71
📒 Files selected for processing (13)
internal/access/resolver_test.gointernal/historyimport/emby_favorites_test.gointernal/historyimport/emby_provider.gointernal/historyimport/emby_provider_test.gointernal/historyimport/service.gointernal/jellycompat/content_direct_test.gointernal/notifications/interest_hooks.gointernal/userdb/conformance_test.gointernal/userdb/favorites.gointernal/userdb/sqlitestore.gointernal/userstore/pgstore/favorites.gointernal/userstore/store.gointernal/watchsync/lists.go
🚧 Files skipped from review as they are similar to previous changes (1)
- internal/historyimport/service.go
Summary
Why
Emby history import previously fetched only played and resumable items, so existing favorites were silently omitted.
Testing
Migration
Adds the additive, non-null history_import_runs.favorites_imported counter with a default of zero.
AI use
Codex assisted with implementation, test design, and review. Every changed line was reviewed and the full verification suite above was run.
Summary by CodeRabbit