31 Commits

Author SHA1 Message Date
Michael Manganiello
e4e3928d1b
misc: Apply import sorting 2025-09-04 11:17:00 -03:00
Michael Manganiello
00d7815889
fix: Improve performance on asset screenshot retrieval
When retrieving the related screenshot for a `Save` or `State`, we were
retrieving a very heavy representation of the associated `Rom` object,
only to iterate through its screenshots to find the one we needed.

This change modifies the `Save` and `State` models to directly query the
`Screenshot` model, which is much faster and more efficient. The
`DBScreenshotsHandler` has been updated to include a new `filter` method
that will simplify building queries using SQLAlchemy, something we can
extend to other handlers in the future.

Fixes #1925.
2025-08-10 15:33:13 -03:00
Georges-Antoine Assi
51652d5084
make all path stuff async 2025-07-18 10:53:55 -04:00
Georges-Antoine Assi
aaf6741e93
Create safe filesystem handler 2025-07-17 12:30:57 -04:00
zurdi
44bfcaa23c
fix: fixed assets path for screenshots 2025-05-14 16:28:46 +00:00
zurdi
14761c2c83
refactor: enhance logging with highlighted output for improved readability 2025-05-09 09:05:59 +00:00
Georges-Antoine Assi
43f48899c9
add new endpoints to get some or all states and saves 2025-03-26 19:21:21 -04:00
Georges-Antoine Assi
c6d6a8100a
wip refactor of save and state behaviour 2025-03-26 17:24:09 -04:00
Georges-Antoine Assi
7d54ef877b
[HOTFIX] Remove single forward-slash endpoints 2025-02-11 13:48:24 -05:00
Michael Manganiello
70825830c4
misc: Set prefix and tags to API routers
Improve OpenAPI documentation by setting tags to each API router. Also,
set a prefix to each router to group the endpoints by their
functionality.
2025-02-09 11:31:13 -03:00
Georges-Antoine Assi
0ef2e03a9e
fixes from migration 2025-01-15 21:56:24 -05:00
Georges-Antoine Assi
696a1c6122
Merge branch 'master' into rom-hashing-background-task 2025-01-15 21:51:23 -05:00
Michael Manganiello
865370ec13
misc: Move auth constants to separate file
This simplifies avoiding circular imports when trying to use auth
handlers.
2025-01-08 22:16:31 -03:00
Georges-Antoine Assi
3fcce6606c
complete updating the endpoints and models 2024-12-20 22:41:56 -05:00
Michael Manganiello
beeb9f0c31
misc: Create enum for authorization scopes
Instead of using just strings, this change converts the scopes to a
`StrEnum`, to be compatible with places where a string is expected. This
avoids typos when using these scopes, simplifies searching for usages,
and improves type hints.

An extra change was the fix to the Firmware download endpoint, which
wasn't respecting the `DISABLE_DOWNLOAD_ENDPOINT_AUTH` flag.
2024-10-18 23:57:42 -03:00
Michael Manganiello
8abbae4c02
misc: Make backend handle URLs with trailing slash
According to multiple FastAPI discussions [1], FastAPI only includes a
built-in mechanism to redirect requests including a trailing slash, to
its variation without slash, using a `307` status code.

This can be an issue when certain clients do not send the same headers
on the redirected request.

This change adds a custom FastAPI `APIRouter`, that registers both route
path variations (with and without trailing slash), while only marking
the path without slash for being included in the OpenAPI schema.

[1] https://github.com/fastapi/fastapi/discussions/7298
2024-08-07 00:22:21 -03:00
Michael Manganiello
8281d5679b
misc: Split database handler logic to get/list entities
The current implementation for some of the database handlers, where the
same method is used to retrieve either a single entity (when an `id` is
passed), a list of entities, or `None`, makes the typing and overall
design more complex.

This change simplifies database handlers, by having two separate methods
where appropiate:

* A method that receives an `id`, and returns either an entity, or `None`.
* A method that optionally receives filters, and returns (depending on
  the current handler implementation) a list of entities, or a `Select`
  object that allows chaining more SQLAlchemy operations.
2024-06-30 13:12:48 -03:00
zurdi
eddc6456b3
fixes from trunk 2024-06-14 20:23:46 +02:00
zurdi
29cf83b791
format from trunk 2024-06-14 20:15:25 +02:00
zurdi
75d93ab564
fixed endpoints 2024-06-13 02:10:39 +02:00
Georges-Antoine Assi
9b62641d55
Merge branch 'master' into trunk-io 2024-05-31 18:42:43 -04:00
Georges-Antoine Assi
2d21cd2b50
Improve speeds of rom fetch from DB 2024-05-25 19:47:36 -04:00
Georges-Antoine Assi
b2085f87a8
bunch of fixes for trunk 2024-05-21 17:10:11 -04:00
Georges-Antoine Assi
2749aaee4a
rename back to old names 2024-05-05 16:59:30 -04:00
Georges-Antoine Assi
9ad28f3294
more refactoring again 2024-05-05 16:32:40 -04:00
Georges-Antoine Assi
def2608c28
refactor db handlers 2024-05-05 15:46:07 -04:00
Georges-Antoine Assi
1a2c914045
refactor handlers out into own files 2024-05-05 12:45:56 -04:00
Georges-Antoine Assi
feb175f02e
General fixes for filtering assets per user 2024-02-07 20:31:03 -05:00
Georges-Antoine Assi
eb18388a81
Mega refactor of asset 2024-02-01 17:59:06 -05:00
Georges-Antoine Assi
38eda35f23
refactor scan_save/state/screenshot 2024-01-25 16:48:51 -05:00
Georges-Antoine Assi
f7da369bcf
correct saving screenshots for states 2024-01-20 22:07:02 -05:00