Skip to content

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

Merged
merged 3 commits into from
Jul 15, 2025

Conversation

zurdi15
Copy link
Member

@zurdi15 zurdi15 commented Jul 15, 2025

Description
Changed to fuzzy match on SGDB cover search when scanning for better results

Checklist
Please check all that apply.

  • 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

@zurdi15 zurdi15 self-assigned this Jul 15, 2025
Copy link

trunk-io bot commented Jul 15, 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.

Copy link
Contributor

@Copilot Copilot AI left a 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 accept dimensions and types 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 to length_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:

Copy link

github-actions bot commented Jul 15, 2025

Test Results

168 tests  ±0   168 ✅ ±0   39s ⏱️ -1s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 1e3977e. ± Comparison against base commit 6643486.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 15, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
7883 4980 63% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
backend/handler/metadata/sgdb_handler.py 43% 🟢
TOTAL 43% 🟢

updated for commit: 1e3977e by action🐍

):
game_details = await self._get_game_covers(
game_id=game["id"],
game_name=game["name"],
types=(SGDBType.STATIC,),
Copy link
Member

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

@zurdi15 zurdi15 merged commit fd95ac0 into master Jul 15, 2025
9 checks passed
@zurdi15 zurdi15 deleted the fix/sgdb-fuzzy-match branch July 15, 2025 15:48
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.

2 participants