changes from self review

This commit is contained in:
Georges-Antoine Assi
2026-02-06 10:31:08 -05:00
parent e36d7650e7
commit 37436fddb7
2 changed files with 11 additions and 13 deletions

View File

@@ -235,19 +235,18 @@ class DBRomsHandler(DBBaseHandler):
return query
def _filter_by_search_term(self, query: Query, search_term: str):
search_terms = search_term.split("|")
conditions = []
terms = [term.strip() for term in search_term.split("|")]
conditions = [
condition
for term in terms
for condition in (
Rom.fs_name.ilike(f"%{term}%"),
Rom.name.ilike(f"%{term}%"),
)
if term
]
for term in search_terms:
term = term.strip()
if term: # Ensure the term is not empty after stripping
conditions.append(Rom.fs_name.ilike(f"%{term}%"))
conditions.append(Rom.name.ilike(f"%{term}%"))
if conditions:
return query.filter(or_(*conditions))
return query
return query.filter(or_(*conditions))
def _filter_by_matched(self, query: Query, value: bool) -> Query:
"""Filter based on whether the rom is matched to a metadata provider.

View File

@@ -106,7 +106,6 @@ def test_filter_last_played(rom: Rom, platform: Platform, admin_user: User):
def test_filter_by_search_term_with_multiple_terms(platform: Platform):
# Create additional ROMs for testing
rom_wwe = db_rom_handler.add_rom(
Rom(
platform_id=platform.id,