mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 18:42:34 +01:00
feat: add missing filter options in API and database handlers for ROMs
This commit is contained in:
@@ -159,6 +159,7 @@ def get_roms(
|
||||
favourites_only: Annotated[bool, Query(deprecated=True)] = False,
|
||||
duplicates_only: Annotated[bool, Query(deprecated=True)] = False,
|
||||
playables_only: Annotated[bool, Query(deprecated=True)] = False,
|
||||
missing_only: Annotated[bool, Query(deprecated=True)] = False,
|
||||
ra_only: bool = False,
|
||||
group_by_meta_id: bool = False,
|
||||
selected_genre: str | None = None,
|
||||
@@ -189,7 +190,8 @@ def get_roms(
|
||||
favourites_only (bool, optional): Filter only favourite roms. Defaults to False. DEPRECATED: use `favourite` instead.
|
||||
duplicates_only (bool, optional): Filter only duplicate roms. Defaults to False. DEPRECATED: use `duplicate` instead.
|
||||
playables_only (bool, optional): Filter only playable roms by emulatorjs. Defaults to False. DEPRECATED: use `playable` instead.
|
||||
ra_only (bool, optional): Filter only roms with Retroachievements compatibility.
|
||||
ra_only (bool, optional): Filter only roms with Retroachievements compatibility. Defaults to False.
|
||||
missing_only (bool, optional): Filter only roms that are missing from the filesystem. Defaults to False.
|
||||
group_by_meta_id (bool, optional): Group roms by igdb/moby/ssrf ID. Defaults to False.
|
||||
selected_genre (str, optional): Filter by genre. Defaults to None.
|
||||
selected_franchise (str, optional): Filter by franchise. Defaults to None.
|
||||
@@ -240,6 +242,7 @@ def get_roms(
|
||||
duplicate=duplicate,
|
||||
playable=playable,
|
||||
ra_only=ra_only,
|
||||
missing_only=missing_only,
|
||||
selected_genre=selected_genre,
|
||||
selected_franchise=selected_franchise,
|
||||
selected_collection=selected_collection,
|
||||
|
||||
@@ -238,6 +238,9 @@ class DBRomsHandler(DBBaseHandler):
|
||||
def filter_by_ra_only(self, query: Query):
|
||||
return query.filter(Rom.ra_id.isnot(None))
|
||||
|
||||
def filter_by_missing_only(self, query: Query):
|
||||
return query.filter(Rom.missing.isnot(False))
|
||||
|
||||
def filter_by_genre(self, query: Query, selected_genre: str):
|
||||
if ROMM_DB_DRIVER == "postgresql":
|
||||
return query.filter(
|
||||
@@ -362,7 +365,8 @@ class DBRomsHandler(DBBaseHandler):
|
||||
favourite: bool | None = None,
|
||||
duplicate: bool | None = None,
|
||||
playable: bool | None = None,
|
||||
ra_only: bool = False,
|
||||
ra_only: bool | None = False,
|
||||
missing_only: bool | None = False,
|
||||
group_by_meta_id: bool = False,
|
||||
selected_genre: str | None = None,
|
||||
selected_franchise: str | None = None,
|
||||
@@ -406,6 +410,9 @@ class DBRomsHandler(DBBaseHandler):
|
||||
if ra_only:
|
||||
query = self.filter_by_ra_only(query)
|
||||
|
||||
if missing_only:
|
||||
query = self.filter_by_missing_only(query)
|
||||
|
||||
if group_by_meta_id:
|
||||
|
||||
def build_func(provider: str, column: InstrumentedAttribute):
|
||||
|
||||
@@ -73,6 +73,7 @@ export interface GetRomsParams {
|
||||
filterDuplicates?: boolean;
|
||||
filterPlayables?: boolean;
|
||||
filterRA?: boolean;
|
||||
filterMissing?: boolean;
|
||||
groupByMetaId?: boolean;
|
||||
selectedGenre?: string | null;
|
||||
selectedFranchise?: string | null;
|
||||
@@ -99,6 +100,7 @@ async function getRoms({
|
||||
filterDuplicates = false,
|
||||
filterPlayables = false,
|
||||
filterRA = false,
|
||||
filterMissing = false,
|
||||
groupByMetaId = false,
|
||||
selectedGenre = null,
|
||||
selectedFranchise = null,
|
||||
@@ -134,6 +136,7 @@ async function getRoms({
|
||||
...(filterFavourites ? { favourite: true } : {}),
|
||||
...(filterDuplicates ? { duplicate: true } : {}),
|
||||
...(filterPlayables ? { playable: true } : {}),
|
||||
...(filterMissing ? { missing_only: true } : {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user