Skip to content
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

Models and API refactor #365

Merged
merged 20 commits into from
Nov 6, 2023
Merged

Models and API refactor #365

merged 20 commits into from
Nov 6, 2023

Conversation

gantoine
Copy link
Member

@gantoine gantoine commented Sep 14, 2023

This is something I've been meaning to do for a while, with the hopes of improving the clarity of some of our models and the relations between them.

ORM

A few fields were deprecated (p_name, p_igdb_id, p_sgdb_id) and a couple more renamed:

  • r_igdb_id -> igdb_id
  • r_sgdb_id -> sgdb_id
  • r_slug -> slug
  • r_name -> name
  • p_slug -> plaforms_slug
  • n_roms -> rom_count

The PRIMARY key for Platform was moved from fs_slug to slug, to clarify that slug is the true identifier for the platform.

  • New relationship between Platform and Rom in the ORM eager joins platform
    • Example: platform_name = rom.platform.name
  • Adds a new decorator begin_session that begins sessions and catches errors
  • Translate methods to use 2.x sqlalchemy syntax

API

  • Now exports a single object by default with all methods on it
    • Means api is now called like so: api.deleteRom({}).then(...)
  • All api methods now accept objects as params
    • No need to worry about order of params
  • Move some values to url params, form inputs or data where appropriate

Other changes

  • Update fastapi + pylance to the latest version
  • Improved error handling for file upload
    • Also cleaned up double-loop
  • Changed most Rom api paths to no longer start with /platform/{p_slug}
  • Rom deletion endpoint accepts delete_from_fs boolean
  • rom_exists -> get_rom_by_filename and returns the Rom (or None)
  • Give all endpoints explicit response types
  • Fixes [Bug] Some games with a / in their title fail to pull IGDB metadata #374

@github-actions
Copy link

github-actions bot commented Sep 14, 2023

Test Results

69 tests  ±0   69 ✔️ ±0   25s ⏱️ +8s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ±0 

Results for commit 87dfeec. ± Comparison against base commit 8b1dfaa.

♻️ This comment has been updated with latest results.

@gantoine gantoine changed the title Models refactor Models and API refactor Sep 14, 2023
@gantoine gantoine marked this pull request as ready for review September 14, 2023 16:00
@gantoine gantoine requested a review from zurdi15 September 14, 2023 16:00
@gantoine gantoine added the refactor Code refactor label Sep 15, 2023
@gantoine gantoine marked this pull request as ready for review November 4, 2023 02:52
@zurdi15
Copy link
Member

zurdi15 commented Nov 4, 2023

Everything seems really good, just some comments about type notations, but nothing important!

backend/alembic/versions/0009_models_refactor.py Outdated Show resolved Hide resolved
backend/alembic/versions/0009_models_refactor.py Outdated Show resolved Hide resolved
backend/handler/igdb_handler.py Show resolved Hide resolved
backend/handler/igdb_handler.py Show resolved Hide resolved
backend/handler/igdb_handler.py Outdated Show resolved Hide resolved
backend/handler/igdb_handler.py Show resolved Hide resolved
backend/handler/igdb_handler.py Show resolved Hide resolved
backend/handler/igdb_handler.py Outdated Show resolved Hide resolved
backend/handler/igdb_handler.py Show resolved Hide resolved
backend/handler/igdb_handler.py Outdated Show resolved Hide resolved
@gantoine gantoine requested a review from zurdi15 November 6, 2023 14:27
@zurdi15 zurdi15 merged commit 0b0bffb into master Nov 6, 2023
5 checks passed
@zurdi15 zurdi15 deleted the models-refactor branch November 6, 2023 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Code refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Some games with a / in their title fail to pull IGDB metadata
2 participants