From b3339c177b79a50d923c365ffac2e06cfccdba6b Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Tue, 17 Feb 2026 15:12:33 -0500 Subject: [PATCH] Run formatter on alembic files --- backend/alembic/versions/0014_asset_files.py | 12 ++--- .../versions/0019_resources_refactor.py | 6 +-- backend/alembic/versions/0021_rom_user.py | 12 ++--- .../versions/0024_sibling_roms_db_view.py | 12 ++--- .../versions/0033_rom_file_and_hashes.py | 24 +++------ .../0034_virtual_collections_db_view.py | 50 ++++++------------- .../versions/0037_virtual_rom_columns.py | 16 ++---- .../versions/0038_add_ssid_to_sibling_roms.py | 12 ++--- .../versions/0040_migrate_assets_paths.py | 14 ++---- .../versions/0041_assets_t_thumb_cleanup.py | 30 +++-------- .../versions/0045_roms_metadata_update.py | 16 ++---- .../versions/0048_sibling_roms_more_ids.py | 12 ++--- .../versions/0050_firmware_add_is_verified.py | 8 +-- .../versions/0052_roms_metadata_flashpoint.py | 16 ++---- .../versions/0055_collection_is_favorite.py | 6 +-- backend/alembic/versions/0057_multi_notes.py | 28 +++-------- .../versions/0058_roms_metadata_launchbox.py | 16 ++---- .../alembic/versions/0061_manual_metadata.py | 16 ++---- .../versions/0062_rom_file_category_enum.py | 12 ++--- .../0063_roms_metadata_player_count.py | 16 ++---- .../versions/0069_sibling_roms_fs_name.py | 12 ++--- backend/alembic/versions/1.8_.py | 6 +-- backend/endpoints/auth.py | 4 +- backend/handler/metadata/base_handler.py | 2 +- backend/handler/metadata/hasheous_handler.py | 3 ++ backend/utils/generate_supported_platforms.py | 6 +-- 26 files changed, 110 insertions(+), 257 deletions(-) diff --git a/backend/alembic/versions/0014_asset_files.py b/backend/alembic/versions/0014_asset_files.py index 2b60964ea..55bf7f1cf 100644 --- a/backend/alembic/versions/0014_asset_files.py +++ b/backend/alembic/versions/0014_asset_files.py @@ -203,14 +203,12 @@ def upgrade() -> None: "update roms set file_name_no_ext = regexp_replace(file_name, '\\.[a-z]{2,}$', '')" ) if is_postgresql(connection): - batch_op.execute( - """ + batch_op.execute(""" UPDATE roms SET platform_id = platforms.id FROM platforms WHERE roms.platform_slug = platforms.slug - """ - ) + """) else: batch_op.execute( "update roms inner join platforms on roms.platform_slug = platforms.slug set roms.platform_id = platforms.id" @@ -270,14 +268,12 @@ def downgrade() -> None: with op.batch_alter_table("roms", schema=None) as batch_op: if is_postgresql(connection): - batch_op.execute( - """ + batch_op.execute(""" UPDATE roms SET platform_slug = platforms.slug FROM platforms WHERE roms.platform_id = platforms.id - """ - ) + """) else: batch_op.execute( "update roms inner join platforms on roms.platform_id = platforms.id set roms.platform_slug = platforms.slug" diff --git a/backend/alembic/versions/0019_resources_refactor.py b/backend/alembic/versions/0019_resources_refactor.py index b6f7957eb..2bb2ff956 100644 --- a/backend/alembic/versions/0019_resources_refactor.py +++ b/backend/alembic/versions/0019_resources_refactor.py @@ -84,15 +84,13 @@ def upgrade() -> None: ) connection.execute( - sa.text( - """ + sa.text(""" UPDATE roms SET path_cover_s = :path_cover_s, path_cover_l = :path_cover_l, path_screenshots = :path_screenshots WHERE id = :id - """ - ), + """), { "id": rom.id, "path_cover_s": updated_path_cover_s, diff --git a/backend/alembic/versions/0021_rom_user.py b/backend/alembic/versions/0021_rom_user.py index 5e94ed94c..9499bc382 100644 --- a/backend/alembic/versions/0021_rom_user.py +++ b/backend/alembic/versions/0021_rom_user.py @@ -44,13 +44,11 @@ def upgrade() -> None: sa.UniqueConstraint("rom_id", "user_id", name="unique_rom_user_props"), ) - op.execute( - """ + op.execute(""" INSERT INTO rom_user (id, updated_at, note_raw_markdown, note_is_public, is_main_sibling, rom_id, user_id) SELECT id, updated_at, raw_markdown, is_public, FALSE, rom_id, user_id FROM rom_notes - """ - ) + """) op.drop_table("rom_notes") # ### end Alembic commands ### @@ -84,13 +82,11 @@ def downgrade() -> None: ) # Copy the data back from the new table to the old table - op.execute( - """ + op.execute(""" INSERT INTO rom_notes (id, updated_at, raw_markdown, is_public, rom_id, user_id) SELECT id, updated_at, note_raw_markdown, note_is_public, rom_id, user_id FROM rom_user - """ - ) + """) # Drop the new table op.drop_table("rom_user") diff --git a/backend/alembic/versions/0024_sibling_roms_db_view.py b/backend/alembic/versions/0024_sibling_roms_db_view.py index 3dc28a86d..90cfe40d2 100644 --- a/backend/alembic/versions/0024_sibling_roms_db_view.py +++ b/backend/alembic/versions/0024_sibling_roms_db_view.py @@ -29,8 +29,7 @@ def upgrade() -> None: ) connection.execute( - sa.text( - f""" + sa.text(f""" CREATE VIEW sibling_roms AS SELECT r1.id AS rom_id, @@ -52,8 +51,7 @@ def upgrade() -> None: OR (r1.moby_id = r2.moby_id AND r1.moby_id IS NOT NULL) ); - """ # nosec B608 - ), + """), # nosec B608 ) @@ -61,11 +59,9 @@ def downgrade() -> None: connection = op.get_bind() connection.execute( - sa.text( - """ + sa.text(""" DROP VIEW sibling_roms; - """ - ), + """), ) with op.batch_alter_table("roms", schema=None) as batch_op: diff --git a/backend/alembic/versions/0033_rom_file_and_hashes.py b/backend/alembic/versions/0033_rom_file_and_hashes.py index ce4b1842e..057a5d32f 100644 --- a/backend/alembic/versions/0033_rom_file_and_hashes.py +++ b/backend/alembic/versions/0033_rom_file_and_hashes.py @@ -82,8 +82,7 @@ def upgrade() -> None: ) if is_postgresql(connection): - op.execute( - """ + op.execute(""" INSERT INTO rom_files ( rom_id, file_name, @@ -107,11 +106,9 @@ def upgrade() -> None: CROSS JOIN jsonb_array_elements(r.files) AS file_data WHERE file_data->>'filename' IS NOT NULL AND file_data->>'filename' <> ''; - """ - ) + """) else: - op.execute( - """ + op.execute(""" INSERT INTO rom_files ( rom_id, file_name, @@ -142,8 +139,7 @@ def upgrade() -> None: ) AS extracted_files WHERE JSON_UNQUOTE(JSON_EXTRACT(file_data, '$.filename')) IS NOT NULL AND JSON_UNQUOTE(JSON_EXTRACT(file_data, '$.filename')) <> ''; - """ - ) + """) with op.batch_alter_table("roms", schema=None) as batch_op: batch_op.alter_column( @@ -210,8 +206,7 @@ def downgrade() -> None: ) if is_postgresql(connection): - op.execute( - """ + op.execute(""" WITH aggregated_data AS ( SELECT rom_id, @@ -234,11 +229,9 @@ def downgrade() -> None: file_size_bytes = aggregated_data.total_size FROM aggregated_data WHERE roms.id = aggregated_data.rom_id; - """ - ) + """) else: - op.execute( - """ + op.execute(""" UPDATE roms JOIN ( SELECT @@ -260,8 +253,7 @@ def downgrade() -> None: roms.files = aggregated_data.files, roms.multi = aggregated_data.multi, roms.file_size_bytes = aggregated_data.total_size; - """ - ) + """) op.drop_table("rom_files") diff --git a/backend/alembic/versions/0034_virtual_collections_db_view.py b/backend/alembic/versions/0034_virtual_collections_db_view.py index 5993af891..ca26ff50d 100644 --- a/backend/alembic/versions/0034_virtual_collections_db_view.py +++ b/backend/alembic/versions/0034_virtual_collections_db_view.py @@ -46,21 +46,16 @@ def upgrade() -> None: connection = op.get_bind() if is_postgresql(connection): - connection.execute( - sa.text( - """ + connection.execute(sa.text(""" INSERT INTO collections_roms (collection_id, rom_id, created_at, updated_at) SELECT c.id, rom_id::INT, NOW(), NOW() FROM collections c, LATERAL jsonb_array_elements_text(c.roms) AS rom_id LEFT JOIN roms r ON rom_id::INT = r.id WHERE r.id IS NOT NULL; - """ - ) - ) + """)) connection.execute( - sa.text( - """ + sa.text(""" CREATE OR REPLACE VIEW virtual_collections AS WITH genres_collection AS ( SELECT @@ -135,25 +130,19 @@ def upgrade() -> None: GROUP BY collection_type, collection_name HAVING COUNT(DISTINCT rom_id) > 2 ORDER BY collection_type, collection_name; - """ # nosec B608 - ), + """), # nosec B608 ) else: - connection.execute( - sa.text( - """ + connection.execute(sa.text(""" INSERT INTO collections_roms (collection_id, rom_id, created_at, updated_at) SELECT c.id, jt.rom_id, NOW(), NOW() FROM collections c JOIN JSON_TABLE(c.roms, '$[*]' COLUMNS (rom_id INT PATH '$')) AS jt LEFT JOIN roms r ON jt.rom_id = r.id WHERE r.id IS NOT NULL; - """ - ) - ) + """)) connection.execute( - sa.text( - """ + sa.text(""" CREATE OR REPLACE VIEW virtual_collections AS WITH genres AS ( SELECT @@ -259,8 +248,7 @@ def upgrade() -> None: GROUP BY collection_type, collection_name HAVING COUNT(DISTINCT rom_id) > 2 ORDER BY collection_type, collection_name; - """ - ), + """), ) op.drop_column("collections", "roms") @@ -272,9 +260,7 @@ def downgrade() -> None: connection = op.get_bind() if is_postgresql(connection): - connection.execute( - sa.text( - """ + connection.execute(sa.text(""" UPDATE collections c SET roms = COALESCE( (SELECT jsonb_agg(rom_id) @@ -282,13 +268,9 @@ def downgrade() -> None: WHERE cr.collection_id = c.id), '[]'::jsonb ); - """ - ) - ) + """)) else: - connection.execute( - sa.text( - """ + connection.execute(sa.text(""" UPDATE collections c JOIN ( SELECT collection_id, IFNULL(JSON_ARRAYAGG(rom_id), JSON_ARRAY()) AS roms @@ -298,9 +280,7 @@ def downgrade() -> None: ON c.id = cr.collection_id SET c.roms = cr.roms; - """ - ) - ) + """)) with op.batch_alter_table("collections", schema=None) as batch_op: batch_op.alter_column("roms", existing_type=CustomJSON(), nullable=False) @@ -308,9 +288,7 @@ def downgrade() -> None: op.drop_table("collections_roms") connection.execute( - sa.text( - """ + sa.text(""" DROP VIEW virtual_collections; - """ - ), + """), ) diff --git a/backend/alembic/versions/0037_virtual_rom_columns.py b/backend/alembic/versions/0037_virtual_rom_columns.py index 61b1dddb8..0a73f6604 100644 --- a/backend/alembic/versions/0037_virtual_rom_columns.py +++ b/backend/alembic/versions/0037_virtual_rom_columns.py @@ -21,9 +21,7 @@ depends_on = None def upgrade(): connection = op.get_bind() if is_postgresql(connection): - connection.execute( - sa.text( - """ + connection.execute(sa.text(""" CREATE OR REPLACE VIEW roms_metadata AS SELECT r.id AS rom_id, @@ -118,13 +116,9 @@ def upgrade(): END AS ss_rating FROM roms r ) AS r; - """ - ) - ) + """)) else: - connection.execute( - sa.text( - """CREATE OR REPLACE VIEW roms_metadata AS + connection.execute(sa.text("""CREATE OR REPLACE VIEW roms_metadata AS SELECT r.id as rom_id, NOW() AS created_at, @@ -220,9 +214,7 @@ def upgrade(): END AS ss_rating FROM roms ) AS r; - """ - ) - ) + """)) def downgrade(): diff --git a/backend/alembic/versions/0038_add_ssid_to_sibling_roms.py b/backend/alembic/versions/0038_add_ssid_to_sibling_roms.py index e536931a8..0d3a0fe1a 100644 --- a/backend/alembic/versions/0038_add_ssid_to_sibling_roms.py +++ b/backend/alembic/versions/0038_add_ssid_to_sibling_roms.py @@ -25,8 +25,7 @@ def upgrade() -> None: ) connection.execute( - sa.text( - f""" + sa.text(f""" CREATE OR REPLACE VIEW sibling_roms AS SELECT r1.id AS rom_id, @@ -51,8 +50,7 @@ def upgrade() -> None: OR (r1.ss_id = r2.ss_id AND r1.ss_id IS NOT NULL) ); - """ # nosec B608 - ), + """), # nosec B608 ) @@ -65,8 +63,7 @@ def downgrade() -> None: connection.execute(sa.text("DROP VIEW IF EXISTS sibling_roms;")) connection.execute( - sa.text( - f""" + sa.text(f""" CREATE VIEW sibling_roms AS SELECT r1.id AS rom_id, @@ -88,6 +85,5 @@ def downgrade() -> None: OR (r1.moby_id = r2.moby_id AND r1.moby_id IS NOT NULL) ); - """ # nosec B608 - ), + """), # nosec B608 ) diff --git a/backend/alembic/versions/0040_migrate_assets_paths.py b/backend/alembic/versions/0040_migrate_assets_paths.py index dd596f49f..16890caeb 100644 --- a/backend/alembic/versions/0040_migrate_assets_paths.py +++ b/backend/alembic/versions/0040_migrate_assets_paths.py @@ -43,15 +43,11 @@ def upgrade() -> None: # Build query based on whether emulator exists select_cols = "id, file_path, rom_id" + (", emulator" if has_emulator else "") - results = conn.execute( - text( - f""" + results = conn.execute(text(f""" SELECT {select_cols} FROM {table} WHERE {like_clause} - """ # nosec B608 - ) - ).fetchall() + """)).fetchall() # nosec B608 for row in results: item_id = row.id @@ -102,13 +98,11 @@ def upgrade() -> None: # Update DB conn.execute( - text( - f""" + text(f""" UPDATE {table} SET file_path = :new_path WHERE id = :item_id - """ # nosec B608 - ), + """), # nosec B608 {"new_path": new_path, "item_id": item_id}, ) diff --git a/backend/alembic/versions/0041_assets_t_thumb_cleanup.py b/backend/alembic/versions/0041_assets_t_thumb_cleanup.py index 8b4addd59..2c817e388 100644 --- a/backend/alembic/versions/0041_assets_t_thumb_cleanup.py +++ b/backend/alembic/versions/0041_assets_t_thumb_cleanup.py @@ -23,20 +23,14 @@ depends_on = None def upgrade() -> None: conn = op.get_bind() - conn.execute( - text( - """ + conn.execute(text(""" UPDATE roms SET url_cover = replace(url_cover, 't_thumb', 't_1080p') WHERE url_cover LIKE '%t_thumb%' - """ - ) - ) + """)) if is_postgresql(conn): - conn.execute( - text( - """ + conn.execute(text(""" UPDATE roms SET url_screenshots = ( SELECT jsonb_agg( @@ -46,19 +40,13 @@ def upgrade() -> None: ) WHERE url_screenshots IS NOT NULL AND url_screenshots::text LIKE '%t_thumb%'; - """ - ) - ) + """)) else: - result = conn.execute( - text( - """ + result = conn.execute(text(""" SELECT id, url_screenshots FROM roms WHERE JSON_SEARCH(url_screenshots, 'one', '%t_thumb%') IS NOT NULL - """ - ) - ) + """)) for row in result: row_id, screenshots_json = row @@ -75,13 +63,11 @@ def upgrade() -> None: for url in screenshots ] conn.execute( - text( - """ + text(""" UPDATE roms SET url_screenshots = :screenshots WHERE id = :id - """ - ), + """), { "screenshots": json.dumps(updated_screenshots), "id": row_id, diff --git a/backend/alembic/versions/0045_roms_metadata_update.py b/backend/alembic/versions/0045_roms_metadata_update.py index e644429fc..fb3acb6d1 100644 --- a/backend/alembic/versions/0045_roms_metadata_update.py +++ b/backend/alembic/versions/0045_roms_metadata_update.py @@ -21,9 +21,7 @@ depends_on = None def upgrade(): connection = op.get_bind() if is_postgresql(connection): - connection.execute( - sa.text( - """ + connection.execute(sa.text(""" CREATE OR REPLACE VIEW roms_metadata AS SELECT r.id AS rom_id, @@ -157,13 +155,9 @@ def upgrade(): END AS launchbox_rating FROM roms r ) AS r; - """ - ) - ) + """)) else: - connection.execute( - sa.text( - """CREATE OR REPLACE VIEW roms_metadata AS + connection.execute(sa.text("""CREATE OR REPLACE VIEW roms_metadata AS SELECT r.id as rom_id, NOW() AS created_at, @@ -294,9 +288,7 @@ def upgrade(): END AS launchbox_rating FROM roms ) AS r; - """ - ) - ) + """)) def downgrade(): diff --git a/backend/alembic/versions/0048_sibling_roms_more_ids.py b/backend/alembic/versions/0048_sibling_roms_more_ids.py index f6eb2fa90..8a9b2bbe5 100644 --- a/backend/alembic/versions/0048_sibling_roms_more_ids.py +++ b/backend/alembic/versions/0048_sibling_roms_more_ids.py @@ -25,8 +25,7 @@ def upgrade() -> None: ) connection.execute( - sa.text( - f""" + sa.text(f""" CREATE OR REPLACE VIEW sibling_roms AS SELECT r1.id AS rom_id, @@ -63,8 +62,7 @@ def upgrade() -> None: OR (r1.tgdb_id = r2.tgdb_id AND r1.tgdb_id IS NOT NULL) ); - """ # nosec B608 - ), + """), # nosec B608 ) @@ -77,8 +75,7 @@ def downgrade() -> None: connection.execute(sa.text("DROP VIEW IF EXISTS sibling_roms;")) connection.execute( - sa.text( - f""" + sa.text(f""" CREATE VIEW sibling_roms AS SELECT r1.id AS rom_id, @@ -103,6 +100,5 @@ def downgrade() -> None: OR (r1.ss_id = r2.ss_id AND r1.ss_id IS NOT NULL) ); - """ # nosec B608 - ), + """), # nosec B608 ) diff --git a/backend/alembic/versions/0050_firmware_add_is_verified.py b/backend/alembic/versions/0050_firmware_add_is_verified.py index 7da49e289..8de90792b 100644 --- a/backend/alembic/versions/0050_firmware_add_is_verified.py +++ b/backend/alembic/versions/0050_firmware_add_is_verified.py @@ -25,15 +25,11 @@ def upgrade() -> None: # Get all firmware records with their hash information connection = op.get_bind() - result = connection.execute( - sa.text( - """ + result = connection.execute(sa.text(""" SELECT f.id, p.slug as platform_slug, f.file_name, f.file_size_bytes, f.md5_hash, f.sha1_hash, f.crc_hash FROM firmware f JOIN platforms p ON f.platform_id = p.id - """ - ) - ) + """)) all_firmware = result.fetchall() verified_firmware_ids = [] diff --git a/backend/alembic/versions/0052_roms_metadata_flashpoint.py b/backend/alembic/versions/0052_roms_metadata_flashpoint.py index 5e4f246e2..e194a8212 100644 --- a/backend/alembic/versions/0052_roms_metadata_flashpoint.py +++ b/backend/alembic/versions/0052_roms_metadata_flashpoint.py @@ -21,9 +21,7 @@ depends_on = None def upgrade(): connection = op.get_bind() if is_postgresql(connection): - connection.execute( - sa.text( - """ + connection.execute(sa.text(""" CREATE OR REPLACE VIEW roms_metadata AS SELECT r.id AS rom_id, @@ -165,13 +163,9 @@ def upgrade(): END AS launchbox_rating FROM roms r ) AS r; - """ - ) - ) + """)) else: - connection.execute( - sa.text( - """CREATE OR REPLACE VIEW roms_metadata AS + connection.execute(sa.text("""CREATE OR REPLACE VIEW roms_metadata AS SELECT r.id as rom_id, NOW() AS created_at, @@ -312,9 +306,7 @@ def upgrade(): END AS launchbox_rating FROM roms ) AS r; - """ - ) - ) + """)) def downgrade(): diff --git a/backend/alembic/versions/0055_collection_is_favorite.py b/backend/alembic/versions/0055_collection_is_favorite.py index d290875b0..fe01c1b0f 100644 --- a/backend/alembic/versions/0055_collection_is_favorite.py +++ b/backend/alembic/versions/0055_collection_is_favorite.py @@ -21,13 +21,11 @@ def upgrade() -> None: batch_op.add_column(sa.Column("is_favorite", sa.Boolean(), nullable=True)) op.execute("UPDATE collections SET is_favorite = FALSE WHERE is_favorite IS NULL") - op.execute( - """ + op.execute(""" UPDATE collections SET is_favorite = TRUE WHERE LOWER(name) IN ('favourites', 'favorites') - """ - ) + """) with op.batch_alter_table("collections", schema=None) as batch_op: batch_op.alter_column("is_favorite", existing_type=sa.Boolean(), nullable=False) diff --git a/backend/alembic/versions/0057_multi_notes.py b/backend/alembic/versions/0057_multi_notes.py index 1fa2e7254..8dfbacd69 100644 --- a/backend/alembic/versions/0057_multi_notes.py +++ b/backend/alembic/versions/0057_multi_notes.py @@ -75,23 +75,17 @@ def upgrade() -> None: # Migrate existing notes from rom_user to rom_notes table # Both note_raw_markdown and note_is_public columns exist from previous migrations connection = op.get_bind() - result = connection.execute( - text( - """ + result = connection.execute(text(""" SELECT id, rom_id, user_id, note_raw_markdown, note_is_public, updated_at FROM rom_user - """ - ) - ) + """)) for row in result: connection.execute( - text( - """ + text(""" INSERT INTO rom_notes (title, content, is_public, tags, created_at, updated_at, rom_id, user_id) VALUES (:title, :content, :is_public, :tags, :created_at, :updated_at, :rom_id, :user_id) - """ - ), + """), { "title": "My Note", "content": row.note_raw_markdown or "", # Handle potential NULL content @@ -125,26 +119,20 @@ def downgrade() -> None: # Migrate notes back to rom_user (take first note per user/rom) connection = op.get_bind() - result = connection.execute( - text( - """ + result = connection.execute(text(""" SELECT DISTINCT rom_id, user_id, FIRST_VALUE(content) OVER (PARTITION BY rom_id, user_id ORDER BY updated_at DESC) as content, FIRST_VALUE(is_public) OVER (PARTITION BY rom_id, user_id ORDER BY updated_at DESC) as is_public FROM rom_notes - """ - ) - ) + """)) for row in result: connection.execute( - text( - """ + text(""" UPDATE rom_user SET note_raw_markdown = :content, note_is_public = :is_public WHERE rom_id = :rom_id AND user_id = :user_id - """ - ), + """), { "content": row.content, "is_public": row.is_public, diff --git a/backend/alembic/versions/0058_roms_metadata_launchbox.py b/backend/alembic/versions/0058_roms_metadata_launchbox.py index 50e1e108b..0b446c7b7 100644 --- a/backend/alembic/versions/0058_roms_metadata_launchbox.py +++ b/backend/alembic/versions/0058_roms_metadata_launchbox.py @@ -21,9 +21,7 @@ depends_on = None def upgrade(): connection = op.get_bind() if is_postgresql(connection): - connection.execute( - sa.text( - """ + connection.execute(sa.text(""" CREATE OR REPLACE VIEW roms_metadata AS SELECT r.id AS rom_id, @@ -185,13 +183,9 @@ def upgrade(): END AS gamelist_rating FROM roms r ) AS r; - """ - ) - ) + """)) else: - connection.execute( - sa.text( - """CREATE OR REPLACE VIEW roms_metadata AS + connection.execute(sa.text("""CREATE OR REPLACE VIEW roms_metadata AS SELECT r.id as rom_id, NOW() AS created_at, @@ -354,9 +348,7 @@ def upgrade(): END AS gamelist_rating FROM roms ) AS r; - """ - ) - ) + """)) def downgrade(): diff --git a/backend/alembic/versions/0061_manual_metadata.py b/backend/alembic/versions/0061_manual_metadata.py index 5fa0e19da..0cca63f39 100644 --- a/backend/alembic/versions/0061_manual_metadata.py +++ b/backend/alembic/versions/0061_manual_metadata.py @@ -34,9 +34,7 @@ def upgrade(): ) if is_postgresql(connection): - connection.execute( - sa.text( - """ + connection.execute(sa.text(""" CREATE OR REPLACE VIEW roms_metadata AS SELECT r.id AS rom_id, @@ -209,13 +207,9 @@ def upgrade(): END AS gamelist_rating FROM roms r ) AS r; - """ - ) - ) + """)) else: - connection.execute( - sa.text( - """CREATE OR REPLACE VIEW roms_metadata AS + connection.execute(sa.text("""CREATE OR REPLACE VIEW roms_metadata AS SELECT r.id as rom_id, NOW() AS created_at, @@ -389,9 +383,7 @@ def upgrade(): END AS gamelist_rating FROM roms ) AS r; - """ - ) - ) + """)) def downgrade(): diff --git a/backend/alembic/versions/0062_rom_file_category_enum.py b/backend/alembic/versions/0062_rom_file_category_enum.py index d184a32c9..6512023fd 100644 --- a/backend/alembic/versions/0062_rom_file_category_enum.py +++ b/backend/alembic/versions/0062_rom_file_category_enum.py @@ -40,23 +40,19 @@ def upgrade() -> None: rom_file_category_enum.create(connection, checkfirst=True) # remove bad values before alter - op.execute( - """ + op.execute(""" UPDATE rom_files SET category = NULL WHERE category IS NOT NULL AND category NOT IN ('GAME', 'DLC', 'HACK', 'MANUAL', 'PATCH', 'UPDATE', 'MOD', 'DEMO', 'TRANSLATION', 'PROTOTYPE') - """ - ) + """) # postgres being picky about needing USING - op.execute( - """ + op.execute(""" ALTER TABLE rom_files ALTER COLUMN category TYPE romfilecategory USING category::text::romfilecategory - """ - ) + """) else: rom_file_category_enum = sa.Enum( diff --git a/backend/alembic/versions/0063_roms_metadata_player_count.py b/backend/alembic/versions/0063_roms_metadata_player_count.py index 12c973de8..b46e1c83f 100644 --- a/backend/alembic/versions/0063_roms_metadata_player_count.py +++ b/backend/alembic/versions/0063_roms_metadata_player_count.py @@ -21,9 +21,7 @@ depends_on = None def upgrade(): connection = op.get_bind() if is_postgresql(connection): - connection.execute( - sa.text( - """ + connection.execute(sa.text(""" CREATE OR REPLACE VIEW roms_metadata AS SELECT r.id AS rom_id, @@ -204,13 +202,9 @@ def upgrade(): END AS gamelist_rating FROM roms r ) AS r; - """ - ) - ) + """)) else: - connection.execute( - sa.text( - """ + connection.execute(sa.text(""" CREATE OR REPLACE VIEW roms_metadata AS SELECT r.id as rom_id, @@ -393,9 +387,7 @@ def upgrade(): END AS gamelist_rating FROM roms ) AS r; - """ - ) - ) + """)) def downgrade(): diff --git a/backend/alembic/versions/0069_sibling_roms_fs_name.py b/backend/alembic/versions/0069_sibling_roms_fs_name.py index 2f009e61f..9ee7f01b3 100644 --- a/backend/alembic/versions/0069_sibling_roms_fs_name.py +++ b/backend/alembic/versions/0069_sibling_roms_fs_name.py @@ -29,8 +29,7 @@ def upgrade() -> None: ) connection.execute( - sa.text( - f""" + sa.text(f""" CREATE OR REPLACE VIEW sibling_roms AS SELECT r1.id AS rom_id, @@ -69,8 +68,7 @@ def upgrade() -> None: OR (r1.fs_name_no_tags = r2.fs_name_no_tags) ); - """ # nosec B608 - ), + """), # nosec B608 ) @@ -82,8 +80,7 @@ def downgrade() -> None: # Restore previous view without fs_name_no_tags fallback connection.execute( - sa.text( - f""" + sa.text(f""" CREATE OR REPLACE VIEW sibling_roms AS SELECT r1.id AS rom_id, @@ -120,8 +117,7 @@ def downgrade() -> None: OR (r1.tgdb_id = r2.tgdb_id AND r1.tgdb_id IS NOT NULL) ); - """ # nosec B608 - ), + """), # nosec B608 ) # Remove the index diff --git a/backend/alembic/versions/1.8_.py b/backend/alembic/versions/1.8_.py index be7a79fe2..0e5a16693 100644 --- a/backend/alembic/versions/1.8_.py +++ b/backend/alembic/versions/1.8_.py @@ -86,8 +86,7 @@ def upgrade() -> None: sa.Column("url_cover", sa.Text(), nullable=True), sa.PrimaryKeyConstraint("id"), ) - batch_op.execute( - "INSERT INTO roms(\ + batch_op.execute("INSERT INTO roms(\ r_igdb_id, p_igdb_id, r_sgdb_id, p_sgdb_id, p_slug, p_name, \ file_name, file_name_no_tags, file_extension, file_path, file_size, \ file_size_units, r_name, r_slug, summary, path_cover_s, path_cover_l, has_cover, \ @@ -97,8 +96,7 @@ def upgrade() -> None: file_name, file_name_no_tags, file_extension, file_path, file_size, \ file_size_units, r_name, r_slug, summary, path_cover_s, path_cover_l, has_cover, \ region, revision, tags, multi, files, url_cover \ - FROM old_roms" - ) + FROM old_roms") op.drop_table("old_roms") # ### end Alembic commands ### diff --git a/backend/endpoints/auth.py b/backend/endpoints/auth.py index 030f2e8a3..a70e87d99 100644 --- a/backend/endpoints/auth.py +++ b/backend/endpoints/auth.py @@ -131,7 +131,7 @@ async def token(form_data: Annotated[OAuth2RequestForm, Depends()]) -> TokenResp return { "access_token": access_token, - "token_type": "bearer", + "token_type": "bearer", # trunk-ignore(bandit/B105) "expires": ACCESS_TOKEN_EXPIRE_MINUTES * 60, } @@ -199,7 +199,7 @@ async def token(form_data: Annotated[OAuth2RequestForm, Depends()]) -> TokenResp return { "access_token": access_token, "refresh_token": refresh_token, - "token_type": "bearer", + "token_type": "bearer", # trunk-ignore(bandit/B105) "expires": ACCESS_TOKEN_EXPIRE_MINUTES * 60, } diff --git a/backend/handler/metadata/base_handler.py b/backend/handler/metadata/base_handler.py index 845cdefa1..6def74777 100644 --- a/backend/handler/metadata/base_handler.py +++ b/backend/handler/metadata/base_handler.py @@ -275,7 +275,7 @@ class MetadataHandler(abc.ABC): return search_term - def _mask_sensitive_values(self, values: dict[str, str | None]) -> dict[str, str]: + def _mask_sensitive_values(self, values: dict[str, str]) -> dict[str, str]: """ Mask sensitive values (headers or params), leaving only the first 2 and last 2 characters of the token. """ diff --git a/backend/handler/metadata/hasheous_handler.py b/backend/handler/metadata/hasheous_handler.py index c0c13c512..76ac5dbc8 100644 --- a/backend/handler/metadata/hasheous_handler.py +++ b/backend/handler/metadata/hasheous_handler.py @@ -103,6 +103,9 @@ def extract_metadata_from_igdb_rom(rom: dict[str, Any]) -> IGDBMetadata: "remasters": [], "similar_games": [], "expanded_games": [], + # TODO: extract multiplayer modes and derive player count + "multiplayer_modes": [], + "player_count": "1", } ) diff --git a/backend/utils/generate_supported_platforms.py b/backend/utils/generate_supported_platforms.py index f7f45853e..b8f3388ad 100644 --- a/backend/utils/generate_supported_platforms.py +++ b/backend/utils/generate_supported_platforms.py @@ -68,10 +68,8 @@ if __name__ == "__main__": sorted(supported_platforms.items(), key=lambda item: item[1]["name"].lower()) ) - print( - """|Platform Name|Folder Name|Metadata Providers| -|---|---|---|""" - ) + print("""|Platform Name|Folder Name|Metadata Providers| +|---|---|---|""") for platform in supported_platforms.values(): print(