-
-
Notifications
You must be signed in to change notification settings - Fork 249
refactor: improve fuzzy matching in SGDBBaseHandler for game search #2079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the SGDBBaseHandler to use a basic fuzzy matching approach when selecting game covers, and makes the cover-fetching method more flexible by parameterizing dimensions and types.
- Introduce
fuzzy_match_threshold
and adjust matching logic to use normalized substring checks and a length-difference threshold - Refactor
_get_game_covers
to acceptdimensions
andtypes
as parameters with defaults instead of hard-coded tuples - Update calls to
_get_game_covers
to leverage the new signature
Comments suppressed due to low confidence (2)
backend/handler/metadata/sgdb_handler.py:34
- [nitpick] The name
fuzzy_match_threshold
implies a general fuzzy algorithm but this value is only used to compare string lengths. Consider renaming tolength_difference_threshold
or implementing a true fuzzy matching method.
self.fuzzy_match_threshold: Final = 4
backend/handler/metadata/sgdb_handler.py:50
- The new fuzzy match behavior isn’t covered by existing tests. Please add unit tests for partial matches, exact matches, and edge cases around the threshold to ensure consistent behavior.
async def get_details_by_names(self, game_names: list[str]) -> SGDBRom:
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
): | ||
game_details = await self._get_game_covers( | ||
game_id=game["id"], | ||
game_name=game["name"], | ||
types=(SGDBType.STATIC,), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nooooo i like getting the animated ones
…shtein distance sorting
Description
Changed to fuzzy match on SGDB cover search when scanning for better results
Checklist
Please check all that apply.
Screenshots