mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 01:58:41 +01:00
* feat(roms): load roms by an array of ids GET /api/roms accepts up to 256 rom_ids and returns those roms in the order given. Ids the caller can't see, or that don't exist, are left out. Closes #5659 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(roms): code-review pass on rom_ids window Reuse RomIdScope (dedupe, shared 500 cap), skip sidecar and grouped page cache reads for a window by id, report offset 0 and the id count as limit, and rename the shadowed rom_ids local in _transform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(roms): simplify pass on rom_ids window Return early for rom_ids before building the filtered query, the sidecars or any cache key, through a shared _hydrate helper, so the paged path is back to its prior shape. Tests use the headers fixture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(roms): review-polish pass, cover a hidden platform in the rom_ids window Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(collections): refuse malformed virtual collection ids, require page-row visibility A malformed virtual_collection_id raised an uncaught decode error (500) on the gallery, random and bulk download routes. It is now a 422 at the query boundary, and GET /collections/virtual/{id} answers 404. get_page_rows_query takes visibility as a required argument, since it is the access check on caller-supplied rom ids. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(gallery): load scroll windows by rom id Once the bootstrap holds the whole ordered id index, a window fetch sends that slice as rom_ids, so the backend skips the filtered, offset-paged query. Items are placed by id, since ids that went missing or hidden are dropped from the response. On a 100k-rom MariaDB library, a filtered grouped window went from 0.8-2.0 s to ~50 ms, and a deep ungrouped window from 106 to 50 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com>
40 lines
901 B
Python
40 lines
901 B
Python
import base64
|
|
|
|
import pytest
|
|
|
|
from models.collection import VirtualCollection
|
|
|
|
|
|
def _encode(raw: str) -> str:
|
|
return base64.urlsafe_b64encode(raw.encode()).decode()
|
|
|
|
|
|
def test_from_id_decodes_an_encoded_id():
|
|
collection = VirtualCollection(name="Racing", type="genre")
|
|
|
|
assert VirtualCollection.from_id(collection.id) == ("Racing", "genre")
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"id_",
|
|
[
|
|
"!!!",
|
|
_encode("not json"),
|
|
_encode("[]"),
|
|
_encode('{"name": "Racing"}'),
|
|
_encode('{"name": 1, "type": "genre"}'),
|
|
"\udcff",
|
|
],
|
|
ids=[
|
|
"not base64",
|
|
"not json",
|
|
"not an object",
|
|
"missing type",
|
|
"non-string name",
|
|
"not ascii",
|
|
],
|
|
)
|
|
def test_from_id_refuses_a_malformed_id(id_: str):
|
|
with pytest.raises(ValueError, match="Invalid virtual collection id"):
|
|
VirtualCollection.from_id(id_)
|