* 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>
Cut the comment blocks that ran past two lines, and rename
platformItems to affectedPlatforms since it holds only the platforms
that have missing firmware, unlike the all-platforms list of the same
name in MissingGamesSection.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The cleanup tasks took a single platform_id while both Missing tabs
offer a multi-select, so picking two platforms ran the unscoped
cleanup over the whole library. The confirmation dialog still named
the selection, so the tab deleted more than it said it would.
Take platform_ids on both cleanup tasks and filter firmware by the
whole list, so what runs matches what the dialog names.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Swap the hand-rolled platform picker in MissingFirmwareSection for the
shared PlatformSelect, and fold the triplicated firmware builder in the
tests into an add_firmware factory fixture.
Keep Platform out of list_firmware: the relationship is lazy="joined",
so every row also ran Platform's rom_count and fs_size_bytes aggregate
subqueries over roms, for data no caller reads.
In useTaskCompletion, the resolver already identifies the live wait, so
drop the parallel generation counter and the unused cancel export.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A scan flags firmware whose file vanished, but nothing could act on the
flag: stale BIOS entries could only be found by opening each platform's
Firmware tab one at a time, the player still offered them (auto-selecting
the sole entry, so the game failed to boot with nothing pointing at the
BIOS), and platform firmware counts included them.
Adds a `missing` filter to the firmware list endpoint, a
`cleanup_missing_firmware` manual task alongside the ROM one, and a
Missing firmware tab in Library management that lists every flagged entry
library-wide with a bulk cleanup. The player now asks for present
firmware only, and firmware selection moved to a `playerFirmware` util
that never picks a missing entry. `firmware_count` counts only firmware
present on disk; the rows themselves still ship so the Firmware tab can
strike them through.
`FirmwareSchema` gains `platform_id` so the library-wide list can group
by platform.
Fixes#4075
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- 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.
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.