Skip to content

feat: Support for multi-value filters#2411

Merged
zurdi15 merged 41 commits intomasterfrom
feat/rom-filter-multivalue
Dec 31, 2025
Merged

feat: Support for multi-value filters#2411
zurdi15 merged 41 commits intomasterfrom
feat/rom-filter-multivalue

Conversation

@adamantike
Copy link
Copy Markdown
Contributor

@adamantike adamantike commented Sep 9, 2025

Description
This change converts the existing single-value ROM filter parameters to support multiple values. Users can now filter ROMs by multiple genres, franchises, collections, companies, age ratings, regions, and languages by repeating the respective query parameters in API requests. It also allow to filter with and or or logic any of those parameters.

Edit from @zurdi15: Added last_played as filter to fix #2816

NOTE: Breaking API change, as the filter parameters have changed names.

Checklist

  • I've tested the changes locally
  • I've updated relevant comments
  • I've assigned reviewers for this PR
  • I've added unit tests that cover the changes

Screenshots:

image

This change converts the existing single-value ROM filter parameters
to support multiple values. Users can now filter ROMs by multiple genres,
franchises, collections, companies, age ratings, regions, and languages by
repeating the respective query parameters in API requests.

At the moment, setting multiple values for a filter will return ROMs
that match any of the provided values (logical OR). A future change can
introduce parameters like `genres_all (boolean)` to allow filtering ROMs
that match all specified values (logical AND).

The frontend has been updated to send single-value filters as arrays
to maintain compatibility with existing UI components. At the moment,
the UI does not support selecting multiple values, but this change
lays the groundwork for it.

NOTE: Breaking API change, as the filter parameters have changed names.
@adamantike adamantike requested a review from gantoine September 9, 2025 03:23
@trunk-io
Copy link
Copy Markdown

trunk-io bot commented Sep 9, 2025

Running Code Quality on PRs by uploading data to Trunk will soon be removed. You can still run checks on your PRs using trunk-action - see the migration guide for more information.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 9, 2025

Test Results

678 tests   677 ✅  1m 17s ⏱️
  1 suites    1 💤
  1 files      0 ❌

Results for commit 647e99f.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 9, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
11995 7742 65% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
backend/endpoints/feeds.py 22% 🟢
backend/endpoints/rom.py 44% 🟢
backend/handler/database/collections_handler.py 50% 🟢
backend/handler/database/roms_handler.py 54% 🟢
backend/tasks/manual/cleanup_orphaned_resources.py 34% 🟢
backend/utils/database.py 45% 🟢
backend/utils/gamelist_exporter.py 13% 🟢
TOTAL 37% 🟢

updated for commit: 006cf2e by action🐍

Copy link
Copy Markdown
Member

@gantoine gantoine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great! 2 questions:

  • is the a migration needed for existing smart collections?
  • do you plan to also change the ui and filters to support multi-select? if not lmk and i can backlog it

…tates, allowing null values for all filters. Update filter logic in the store and API services to accommodate new states. Enhance UI for better visibility and interaction with filter options in the gallery app.
…re, franchise, collection, company, age rating, region, and language. Update serialization logic to maintain query parameters on refresh.
…res, franchises, collections, companies, age ratings, regions, and languages. Update API and frontend components to support new filter states and logic. Refactor gallery filter store and API service to accommodate multi-value selections and maintain backward compatibility with single-value filters. Improve UI for filter options in the gallery app, including logic toggle buttons for better user interaction.
…c operator parameters, streamline multi-platform handling in API and frontend components.
…management to clear single platform selection
…port multi-value filtering in API and frontend components
@zurdi15
Copy link
Copy Markdown
Member

zurdi15 commented Nov 27, 2025

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces significant and well-implemented support for multi-value filters on ROMs, a great enhancement for the API and frontend. The backend changes correctly adapt the database queries, and the frontend UI has been impressively revamped to support multi-selection and AND/OR logic. I've identified a couple of areas for improvement in the backend concerning input sanitization for robustness and clarity, and a minor code duplication issue on the frontend. Overall, this is a solid contribution.

@zurdi15
Copy link
Copy Markdown
Member

zurdi15 commented Nov 28, 2025

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant and well-implemented feature: multi-value ROM filters. The changes span the backend API, database handlers, and frontend components, enabling users to filter by multiple genres, franchises, and other criteria. The refactoring in both the backend and frontend is excellent, particularly the move to a more data-driven approach for applying filters and the improved UI for filter selection.

My review has identified a couple of areas for improvement. There's a bug in how smart collections handle multi-platform filters, and the 'Create Smart Collection' dialog hasn't been fully updated to support the new multi-value filtering capabilities. I've also made a suggestion to improve backward compatibility for existing smart collections. Addressing these points will make this already strong feature even more robust.

…ections for genres, franchises, collections, companies, age ratings, regions, and languages
@zurdi15 zurdi15 marked this pull request as ready for review December 1, 2025 16:58
@zurdi15 zurdi15 changed the title feat: Initial support for multi-value ROM filters feat: Initial support for multi-value filters Dec 25, 2025
@zurdi15 zurdi15 changed the title feat: Initial support for multi-value filters feat: Support for multi-value filters Dec 30, 2025
Copy link
Copy Markdown
Member

@gantoine gantoine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very clean implementation and easy to review 🤘🏼

companies = convert_legacy_filter("companies", "selected_company")
age_ratings = convert_legacy_filter("age_ratings", "selected_age_rating")
regions = convert_legacy_filter("regions", "selected_region")
languages = convert_legacy_filter("languages", "selected_language")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

Copy link
Copy Markdown
Member

@zurdi15 zurdi15 Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, now self revieweing again the code I removed the old parameters. Should we remove the convert_legavy_filter or do you think it's better to re-add the old single-value parameters?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question, not sure but do what you think is best and we'll test in staging using exisiting smart collections.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ili'll leave itt here to not mess with already existing smart collections

predicate = RomUser.last_played.isnot(None)
if not value:
predicate = RomUser.last_played.is_(None)
return query.filter(predicate)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

}
});

return searchParams.toString();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@zurdi15 zurdi15 merged commit 6295d5b into master Dec 31, 2025
9 checks passed
@zurdi15 zurdi15 deleted the feat/rom-filter-multivalue branch December 31, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Continue Playing entries reappear and can't be removed on 4.5.0

3 participants