Commit Graph

41 Commits

Author SHA1 Message Date
Sam Dornan
fd9a33bc35 fix(backend): return identifiers without building an ORM row per id (#4586)
* fix(backend): project the identifier endpoints onto the id column

The `/identifiers` routes for saves, states, firmware, platforms, smart
collections and rom notes each asked their handler for entities with
`only_fields=[Model.id]`. `load_only` narrows the selected columns but does
not cancel an eager relationship, so a `lazy="joined"` join still fired and a
full entity was still built for every row. The platforms route was the worst
of the six: `with_firmware` eager-loads every firmware row and its platform,
and `load_only` does not cancel that either.

Each handler grows a small query builder shared by its existing accessor and a
new `*_ids` accessor that projects onto the id column with
`with_only_columns`, which drops the entity and with it the eager joins. The
firmware accessor already applied `noload`, so its SQL is unchanged; it moves
to the projection only to stop building rows.

`/api/users/identifiers` and the two `/collections` callers that use more than
an id are left alone, because nothing eager fires for them.

The `executed_statements` fixture moves to `tests/conftest.py` so the new
endpoint tests can use it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Update backend/tests/endpoints/test_identifier_endpoints.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* style(backend): drop the leading blank line black rejects

Removing the module docstring in the GitHub edit left an empty first line,
which is the only thing black wanted to change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(backend): drive the note-identifier test through the endpoint

Greptile flagged the handler-level test for bypassing the route's auth,
404, and visibility checks. It now issues the request the frontend would
and asserts the id-only projection holds among the route's own reads.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* refactor(backend): fold the duplicate SQL-capture fixtures into the shared one

Step 3 of the PR-ready gauntlet (simplify). The shared
`executed_statements` fixture gains the two roms test files that still
declared byte-identical local copies, and the id-only assertions share one
statement parser instead of two.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(backend): tighten the get_platform_ids docstring to one line

Step 4 of the PR-ready gauntlet (review-polish).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-09-17 11:13:07 -05:00
zurdi
649ddce2aa feat: Implement fine-grained permission checks and admin CRUD for permission groups
- Added new permission handling in `backend/handler/auth/dependencies.py` to support fine-grained, DB-backed permission checks.
- Enhanced user role update logic in `backend/endpoints/user.py` to prevent demotion of the last admin.
- Introduced `hidden_platform_ids` and `hidden_rom_ids` parameters in various database handlers to manage visibility based on admin settings.
- Created new endpoints for managing permission groups, user memberships, and hidden entities in `backend/tests/endpoints/test_permissions_admin.py`.
- Added tests for permissions visibility and CRUD operations in `backend/tests/endpoints/test_permissions_visibility.py` and `backend/tests/endpoints/test_permissions_me.py`.
- Updated archive handling in `backend/utils/archives.py` to improve error logging and timeout management during extraction.
2026-06-24 08:45:45 +00:00
Georges-Antoine Assi
bddb7bd9f5 manual cleanup 2026-01-18 22:27:46 -05:00
Georges-Antoine Assi
54bfb3fec5 DB functions accept list of params 2026-01-18 21:26:48 -05:00
Brandon T. Kowalski
5b5dc68f58 Added updated_after query parameter for platform and rom endpoints. 2026-01-12 19:37:36 -05:00
Georges-Antoine Assi
8078941bd1 [ROMM-2856] Use platform slug to fetch feed games 2026-01-03 12:38:26 -05:00
Georges-Antoine Assi
19ef2d4d5f type ignore session and query attrs 2025-12-12 17:05:12 -05:00
Michael Manganiello
e4e3928d1b misc: Apply import sorting 2025-09-04 11:17:00 -03:00
Georges-Antoine Assi
048f8ba248 move fs_size_bytes back to db 2025-08-19 19:38:56 -04:00
Michael Manganiello
252722e3bc misc: Apply pyupgrade changes for Python 3.12 compatibility
Command applied:
```
find ./backend/ -type f -name "*.py" -exec pyupgrade --py312-plus {} \;
```
2025-06-29 12:27:16 -03:00
zurdi
8370b79a83 feat: add 'missing_from_fs' property to various schemas and update related logic for better tracking of missing files 2025-06-12 22:18:06 +00:00
zurdi
dab9421ec6 fix: update rom missing status handling in scan and platform handlers 2025-06-12 08:11:08 +00:00
zurdi
b52ea89115 feat: add 'missing' flag to platforms and roms, update related handlers and schemas 2025-06-12 01:20:20 +00:00
Georges-Antoine Assi
ca6d312c4a fix tests 2025-03-21 09:42:39 -04:00
Georges-Antoine Assi
581cdf742c fix pagination speeds 2025-03-21 00:07:27 -04:00
Georges-Antoine Assi
1952f80b87 fix the rest of the tests 2024-12-22 17:00:35 -05:00
Georges-Antoine Assi
2e4e557eef fixup running scans and loading 2024-12-21 12:06:37 -05:00
Georges-Antoine Assi
3fcce6606c complete updating the endpoints and models 2024-12-20 22:41:56 -05:00
Georges-Antoine Assi
49c50ad810 Move hash calc for roms to bacakground task 2024-12-19 22:21:51 -05:00
zurdi
a51dd03e1a Added full offline support and configurable logging level and API requests debug logs 2024-11-27 17:12:13 +00:00
Georges-Antoine Assi
e4816911d9 Better performance for large collections 2024-08-28 11:44:31 -04:00
Michael Manganiello
2bfc3c4c7e misc: Refactor scan process by splitting single function
This change mainly refactors the `scan_platforms` function, moving part
of its logic to `_identify_platform`, `_identify_firmware`, and
`_identify_rom`.

The logic is simpler this way, each smaller function returns `ScanStats`
that can be merged by the caller, and it simplifies future performance
improvements.
2024-07-25 10:29:46 -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
Georges-Antoine Assi
7635bbeac2 run trunk fixes 2024-05-24 16:59:54 -04:00
Georges-Antoine Assi
b075e93321 Merge branch 'master' into trunk-io 2024-05-24 16:47:19 -04:00
Georges-Antoine Assi
d99c1996ae use platforms store + fix scan 2024-05-24 12:01:47 -04:00
Georges-Antoine Assi
2d4d1b5ae3 improve roms loading time 2024-05-24 10:14:44 -04:00
Georges-Antoine Assi
ac59fa16eb hotfix scanning rom_count field 2024-05-24 09:56:41 -04:00
Georges-Antoine Assi
8eddd03665 fix tests 2024-05-23 23:50:41 -04:00
Georges-Antoine Assi
2b1f4e59c9 typo fixes 2024-05-23 23:29:55 -04:00
Georges-Antoine Assi
7c5da34ddf fix slow fetching of platform 2024-05-23 23:18:19 -04:00
Georges-Antoine Assi
ca1363a93c run chech 2024-05-23 10:14:04 -04:00
Georges-Antoine Assi
10479bdc9f run formatter 2024-05-23 10:06:43 -04:00
Georges-Antoine Assi
fcb34f9088 Merge branch 'master' into trunk-io 2024-05-23 10:06:13 -04:00
Georges-Antoine Assi
1840390c8a finish mypy fixes 2024-05-21 21:28:17 -04:00
Georges-Antoine Assi
9fc8267646 run ruff 2024-05-19 14:39:13 -04:00
Georges-Antoine Assi
e72a1d8851 Merge branch 'master' into platform-fetch-perf-improvements 2024-05-19 14:28:53 -04:00
Georges-Antoine Assi
fffc954750 fix tests 2024-05-19 13:06:11 -04:00
Georges-Antoine Assi
6735be4ce8 add query preloader for roms 2024-05-19 11:25:46 -04:00
Georges-Antoine Assi
7fbcc88043 [ROMM-852] Purge platforms correctly on scan 2024-05-19 10:51:18 -04:00
Georges-Antoine Assi
dc33054ba1 more name refactoring 2024-05-05 16:45:58 -04:00