mirror of
https://github.com/rommapp/romm.git
synced 2026-02-19 07:50:57 +01:00
[ROMM-2668] Speedup feeds endpoint
This commit is contained in:
@@ -215,7 +215,7 @@ async def tinfoil_index_feed(
|
||||
size=rom_file.file_size_bytes,
|
||||
)
|
||||
for rom in roms
|
||||
for rom_file in db_rom_handler.get_rom_files(rom.id)
|
||||
for rom_file in rom.files
|
||||
if rom_file.file_extension in ["xci", "nsp", "nsz", "xcz", "nro"]
|
||||
],
|
||||
directories=[],
|
||||
@@ -298,7 +298,7 @@ def pkgi_ps3_feed(
|
||||
txt_lines = []
|
||||
|
||||
for rom in roms:
|
||||
for file in db_rom_handler.get_rom_files(rom.id):
|
||||
for file in rom.files:
|
||||
if not validate_pkgi_file(file, content_type_enum):
|
||||
continue
|
||||
|
||||
@@ -369,7 +369,7 @@ def pkgi_psvita_feed(
|
||||
txt_lines = []
|
||||
|
||||
for rom in roms:
|
||||
for file in db_rom_handler.get_rom_files(rom.id):
|
||||
for file in rom.files:
|
||||
if not validate_pkgi_file(file, content_type_enum):
|
||||
continue
|
||||
|
||||
@@ -440,7 +440,7 @@ def pkgi_psp_feed(
|
||||
txt_lines = []
|
||||
|
||||
for rom in roms:
|
||||
for file in db_rom_handler.get_rom_files(rom.id):
|
||||
for file in rom.files:
|
||||
if not validate_pkgi_file(file, content_type_enum):
|
||||
continue
|
||||
|
||||
|
||||
@@ -564,7 +564,7 @@ async def head_rom_content(
|
||||
if not rom:
|
||||
raise RomNotFoundInDatabaseException(id)
|
||||
|
||||
files = list(db_rom_handler.get_rom_files(rom.id))
|
||||
files = rom.files
|
||||
if file_ids:
|
||||
file_id_values = {int(f.strip()) for f in file_ids.split(",") if f.strip()}
|
||||
files = [f for f in files if f.id in file_id_values]
|
||||
@@ -641,7 +641,7 @@ async def get_rom_content(
|
||||
# https://muos.dev/help/addcontent#what-about-multi-disc-content
|
||||
hidden_folder = safe_str_to_bool(request.query_params.get("hidden_folder", ""))
|
||||
|
||||
files = list(db_rom_handler.get_rom_files(rom.id))
|
||||
files = rom.files
|
||||
if file_ids:
|
||||
file_id_values = {int(f.strip()) for f in file_ids.split(",") if f.strip()}
|
||||
files = [f for f in files if f.id in file_id_values]
|
||||
|
||||
@@ -120,7 +120,9 @@ def with_details(func):
|
||||
),
|
||||
selectinload(Rom.rom_users).options(noload(RomUser.rom)),
|
||||
selectinload(Rom.metadatum).options(noload(RomMetadata.rom)),
|
||||
selectinload(Rom.files).options(noload(RomFile.rom)),
|
||||
selectinload(Rom.files).options(
|
||||
joinedload(RomFile.rom).load_only(Rom.fs_path, Rom.fs_name)
|
||||
),
|
||||
selectinload(Rom.sibling_roms).options(
|
||||
noload(Rom.platform), noload(Rom.metadatum)
|
||||
),
|
||||
@@ -142,7 +144,9 @@ def with_simple(func):
|
||||
# Sort table by metadata (first_release_date)
|
||||
selectinload(Rom.metadatum).options(noload(RomMetadata.rom)),
|
||||
# Required for multi-file ROM actions and 3DS QR code
|
||||
selectinload(Rom.files).options(noload(RomFile.rom)),
|
||||
selectinload(Rom.files).options(
|
||||
joinedload(RomFile.rom).load_only(Rom.fs_path, Rom.fs_name)
|
||||
),
|
||||
# Show sibling rom badges on cards
|
||||
selectinload(Rom.sibling_roms).options(
|
||||
noload(Rom.platform), noload(Rom.metadatum)
|
||||
@@ -831,10 +835,6 @@ class DBRomsHandler(DBBaseHandler):
|
||||
def add_rom_file(self, rom_file: RomFile, session: Session = None) -> RomFile:
|
||||
return session.merge(rom_file)
|
||||
|
||||
@begin_session
|
||||
def get_rom_files(self, rom_id: int, session: Session = None) -> Sequence[RomFile]:
|
||||
return session.scalars(select(RomFile).filter_by(rom_id=rom_id)).all()
|
||||
|
||||
@begin_session
|
||||
def get_rom_file_by_id(self, id: int, session: Session = None) -> RomFile | None:
|
||||
return session.scalar(select(RomFile).filter_by(id=id).limit(1))
|
||||
|
||||
Reference in New Issue
Block a user