Add preferred release groups for auto-download and filtering#491
Add preferred release groups for auto-download and filtering#491Doezer merged 9 commits intorelease/1.3.0from
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request implements a 'Preferred Release Groups' feature, enabling users to prioritize specific release groups for auto-downloads and filter search results. The changes include a new settings UI component, database schema updates, and logic in the auto-search cron job to apply these preferences. Review feedback highlights a critical stability risk where malformed JSON could crash the cron job and recommends refactoring duplicated parsing and filtering logic into shared helper functions to improve maintainability and error handling.
…ring - Add preferredReleaseGroups and filterByPreferredGroups to userSettings schema - Migration 0008 adds the two new columns to user_settings table - Auto-download now filters candidates to preferred groups before the single/multiple result decision; falls back to all results if no match - Download Started notification includes the release group name - New PreferredReleaseGroupsSettings component with tag input and pre-filter toggle - Settings Rules tab renders the new component - GameDownloadDialog pre-populates selected groups from preferred groups when filterByPreferredGroups is enabled Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…games loop Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Wrap JSON.parse of preferredReleaseGroups in try-catch with Array.isArray guard in cron.ts to prevent cron job crash on malformed data - Extract duplicated preferred-groups filter logic into applyPreferredGroupsFilter helper, replacing identical blocks in both wanted-games and owned-games loops - Add console.warn to empty catch block in GameDownloadDialog.tsx - Add Array.isArray guard and console.warn to settings.tsx JSON.parse Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
854861a to
6fcbceb
Compare
|
Add way to add new release group to the list from search download view |
Doezer
left a comment
There was a problem hiding this comment.
Addressed all four review comments in commit 45579c2 (rebased onto release/1.3.0):\n\n1. [CRITICAL] cron.ts JSON.parse crash — Wrapped in try-catch with Array.isArray guard; logs a warning on malformed data.\n2. [MEDIUM] Duplicated filter logic — Extracted to applyPreferredGroupsFilter helper; both mainItems and updateItems loops now use it.\n3. [MEDIUM] GameDownloadDialog empty catch — Added console.warn with the error.\n4. [MEDIUM] settings.tsx unsafe cast — Added Array.isArray guard and console.warn in catch.\n\nAll lint, type-check, and tests (659/659) pass.
- Add 9 tests covering applyPreferredGroupsFilter behavior: - Filter multiple results to single preferred-group match - Fallback to all items when no items match preferred groups - Empty array skips filtering - Malformed JSON handled gracefully without crashing - Non-array JSON treated as no filter - Group suffix in Download Started notification - No group suffix when item has no group - Preferred groups applied to owned-game update items - Add mockUpdateGameStatus, mockAddGameDownload, mockAddDownloadWithFallback - Update baseSettings with preferredReleaseGroups, filterByPreferredGroups, steamSyncFailures
Add parseJsonStringArray helper to shared/title-utils.ts and replace the duplicated JSON.parse + Array.isArray + try/catch pattern in cron.ts, settings.tsx, and GameDownloadDialog.tsx. Fixes SonarCloud new_duplicated_lines_density hotspot on PR #491.
- closes dialog after successful download (mockOnOpenChange) - shows destructive toast when API returns success:false - displays indexer errors from search response - shows bundle dialog when main item clicked with updates available - filters results to preferred group when filterByPreferredGroups enabled - shows all results when filterByPreferredGroups is false Also exposes mockToast and mockOnOpenChange for assertion in tests.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…earch tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
* feat: add preferred release groups for auto-download and search filtering - Add preferredReleaseGroups and filterByPreferredGroups to userSettings schema - Migration 0008 adds the two new columns to user_settings table - Auto-download now filters candidates to preferred groups before the single/multiple result decision; falls back to all results if no match - Download Started notification includes the release group name - New PreferredReleaseGroupsSettings component with tag input and pre-filter toggle - Settings Rules tab renders the new component - GameDownloadDialog pre-populates selected groups from preferred groups when filterByPreferredGroups is enabled Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: hoist preferredGroups parsing outside per-game loop Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: apply preferred release groups filter to update items in owned-games loop Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: address Gemini review comments on preferred release groups - Wrap JSON.parse of preferredReleaseGroups in try-catch with Array.isArray guard in cron.ts to prevent cron job crash on malformed data - Extract duplicated preferred-groups filter logic into applyPreferredGroupsFilter helper, replacing identical blocks in both wanted-games and owned-games loops - Add console.warn to empty catch block in GameDownloadDialog.tsx - Add Array.isArray guard and console.warn to settings.tsx JSON.parse Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test: add preferred release groups coverage to cron_autosearch - Add 9 tests covering applyPreferredGroupsFilter behavior: - Filter multiple results to single preferred-group match - Fallback to all items when no items match preferred groups - Empty array skips filtering - Malformed JSON handled gracefully without crashing - Non-array JSON treated as no filter - Group suffix in Download Started notification - No group suffix when item has no group - Preferred groups applied to owned-game update items - Add mockUpdateGameStatus, mockAddGameDownload, mockAddDownloadWithFallback - Update baseSettings with preferredReleaseGroups, filterByPreferredGroups, steamSyncFailures * refactor: extract parseJsonStringArray to eliminate code duplication Add parseJsonStringArray helper to shared/title-utils.ts and replace the duplicated JSON.parse + Array.isArray + try/catch pattern in cron.ts, settings.tsx, and GameDownloadDialog.tsx. Fixes SonarCloud new_duplicated_lines_density hotspot on PR #491. * test: expand GameDownloadDialog coverage with 6 new scenarios - closes dialog after successful download (mockOnOpenChange) - shows destructive toast when API returns success:false - displays indexer errors from search response - shows bundle dialog when main item clicked with updates available - filters results to preferred group when filterByPreferredGroups enabled - shows all results when filterByPreferredGroups is false Also exposes mockToast and mockOnOpenChange for assertion in tests. * refactor: extract createFetchMock helper to eliminate test duplication Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: extract shared fixtures to reduce duplication in cron autosearch tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat: add preferred release groups for auto-download and search filtering - Add preferredReleaseGroups and filterByPreferredGroups to userSettings schema - Migration 0008 adds the two new columns to user_settings table - Auto-download now filters candidates to preferred groups before the single/multiple result decision; falls back to all results if no match - Download Started notification includes the release group name - New PreferredReleaseGroupsSettings component with tag input and pre-filter toggle - Settings Rules tab renders the new component - GameDownloadDialog pre-populates selected groups from preferred groups when filterByPreferredGroups is enabled Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: hoist preferredGroups parsing outside per-game loop Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: apply preferred release groups filter to update items in owned-games loop Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: address Gemini review comments on preferred release groups - Wrap JSON.parse of preferredReleaseGroups in try-catch with Array.isArray guard in cron.ts to prevent cron job crash on malformed data - Extract duplicated preferred-groups filter logic into applyPreferredGroupsFilter helper, replacing identical blocks in both wanted-games and owned-games loops - Add console.warn to empty catch block in GameDownloadDialog.tsx - Add Array.isArray guard and console.warn to settings.tsx JSON.parse Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test: add preferred release groups coverage to cron_autosearch - Add 9 tests covering applyPreferredGroupsFilter behavior: - Filter multiple results to single preferred-group match - Fallback to all items when no items match preferred groups - Empty array skips filtering - Malformed JSON handled gracefully without crashing - Non-array JSON treated as no filter - Group suffix in Download Started notification - No group suffix when item has no group - Preferred groups applied to owned-game update items - Add mockUpdateGameStatus, mockAddGameDownload, mockAddDownloadWithFallback - Update baseSettings with preferredReleaseGroups, filterByPreferredGroups, steamSyncFailures * refactor: extract parseJsonStringArray to eliminate code duplication Add parseJsonStringArray helper to shared/title-utils.ts and replace the duplicated JSON.parse + Array.isArray + try/catch pattern in cron.ts, settings.tsx, and GameDownloadDialog.tsx. Fixes SonarCloud new_duplicated_lines_density hotspot on PR #491. * test: expand GameDownloadDialog coverage with 6 new scenarios - closes dialog after successful download (mockOnOpenChange) - shows destructive toast when API returns success:false - displays indexer errors from search response - shows bundle dialog when main item clicked with updates available - filters results to preferred group when filterByPreferredGroups enabled - shows all results when filterByPreferredGroups is false Also exposes mockToast and mockOnOpenChange for assertion in tests. * refactor: extract createFetchMock helper to eliminate test duplication Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: extract shared fixtures to reduce duplication in cron autosearch tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat: add preferred release groups for auto-download and search filtering - Add preferredReleaseGroups and filterByPreferredGroups to userSettings schema - Migration 0008 adds the two new columns to user_settings table - Auto-download now filters candidates to preferred groups before the single/multiple result decision; falls back to all results if no match - Download Started notification includes the release group name - New PreferredReleaseGroupsSettings component with tag input and pre-filter toggle - Settings Rules tab renders the new component - GameDownloadDialog pre-populates selected groups from preferred groups when filterByPreferredGroups is enabled Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: hoist preferredGroups parsing outside per-game loop Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: apply preferred release groups filter to update items in owned-games loop Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: address Gemini review comments on preferred release groups - Wrap JSON.parse of preferredReleaseGroups in try-catch with Array.isArray guard in cron.ts to prevent cron job crash on malformed data - Extract duplicated preferred-groups filter logic into applyPreferredGroupsFilter helper, replacing identical blocks in both wanted-games and owned-games loops - Add console.warn to empty catch block in GameDownloadDialog.tsx - Add Array.isArray guard and console.warn to settings.tsx JSON.parse Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test: add preferred release groups coverage to cron_autosearch - Add 9 tests covering applyPreferredGroupsFilter behavior: - Filter multiple results to single preferred-group match - Fallback to all items when no items match preferred groups - Empty array skips filtering - Malformed JSON handled gracefully without crashing - Non-array JSON treated as no filter - Group suffix in Download Started notification - No group suffix when item has no group - Preferred groups applied to owned-game update items - Add mockUpdateGameStatus, mockAddGameDownload, mockAddDownloadWithFallback - Update baseSettings with preferredReleaseGroups, filterByPreferredGroups, steamSyncFailures * refactor: extract parseJsonStringArray to eliminate code duplication Add parseJsonStringArray helper to shared/title-utils.ts and replace the duplicated JSON.parse + Array.isArray + try/catch pattern in cron.ts, settings.tsx, and GameDownloadDialog.tsx. Fixes SonarCloud new_duplicated_lines_density hotspot on PR #491. * test: expand GameDownloadDialog coverage with 6 new scenarios - closes dialog after successful download (mockOnOpenChange) - shows destructive toast when API returns success:false - displays indexer errors from search response - shows bundle dialog when main item clicked with updates available - filters results to preferred group when filterByPreferredGroups enabled - shows all results when filterByPreferredGroups is false Also exposes mockToast and mockOnOpenChange for assertion in tests. * refactor: extract createFetchMock helper to eliminate test duplication Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: extract shared fixtures to reduce duplication in cron autosearch tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>


This pull request adds support for users to specify and manage "preferred release groups" for game downloads. Users can now prioritize downloads from specific release groups, both in the UI and in the automatic download logic. The implementation includes database schema changes, UI components for configuration, and backend logic to honor these preferences during searches and downloads.
User Settings and Database Changes:
user_settingstable and schema:preferred_release_groups(a JSON-encoded list of group names) andfilter_by_preferred_groups(a boolean to enable/disable filtering by these groups). [1] [2]Frontend: User Interface for Preferred Groups:
PreferredReleaseGroupsSettingscomponent in the settings page, allowing users to add, remove, and save preferred release groups, as well as toggle filtering. [1] [2] [3] [4] [5]Backend: Auto-Search and Download Filtering:
server/cron.tsto filter both main and update search results by preferred release groups when configured, ensuring only matching releases are considered if any are available. [1] [2] [3]Closes #392