Commit Graph

28 Commits

Author SHA1 Message Date
Georges-Antoine Assi
753556af7b perf(backend): materialize virtual collection membership
virtual_collections was a view that unnested five JSON arrays per rom on
every read, so both the collection list and opening a single collection
scanned the whole library. Opening a collection with a handful of roms
cost as much as one with thousands, since the name is computed inside the
view and nothing can be narrowed down early.

Membership now lives in virtual_collection_roms, one narrow row per
(type, name, rom_id) plus that rom's covers, derived from the generated_*
columns and maintained by triggers on roms (deletions ride the foreign
key cascade). The view becomes a plain aggregate over that table, so the
model, schemas and API shape are unchanged, and filtering roms by a
virtual collection is an indexed subquery instead of an IN list of every
member id.

Covers are no longer aggregated in the view, which materialized every
member's cover path on every request; the handler resolves at most five
per collection, matching the smart collection cap and what both UIs
render.

On a synthetic 50k-rom library the list goes from 1.42s to 0.128s and a
single collection from 0.111s to 0.0006s, with identical output.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 10:06:05 -04:00
Georges-Antoine Assi
c6e9ce5bbd filter out non-owned collections when adding 2026-02-08 09:52:55 -05:00
Georges-Antoine Assi
6ccae17eb3 stoer favorites on collection 2025-10-17 18:19:40 -04:00
Georges-Antoine Assi
69b697034c fix loading missing covers virtula collection 2025-09-05 23:02:47 -04:00
Michael Manganiello
e4e3928d1b misc: Apply import sorting 2025-09-04 11:17:00 -03:00
Georges-Antoine Assi
0cc9789a12 fix get_scalar_roms 2025-08-19 23:40:23 -04:00
Georges-Antoine Assi
cde0c0681f changes from review 2025-08-19 17:07:05 -04:00
Georges-Antoine Assi
5a5abe4e62 changes from self review 2025-08-19 16:27:46 -04:00
Georges-Antoine Assi
0dadf8681e fix updating smart collections 2025-08-19 15:53:03 -04:00
Georges-Antoine Assi
13ac6104ce Raise lazy joins so all complex joins are explicit 2025-08-19 10:02:11 -04:00
Georges-Antoine Assi
9f53f6eccc complete smart collection 2025-07-25 17:37:55 -04:00
Georges-Antoine Assi
1a57ff2c6b complete cycle of creation 2025-07-25 17:24:38 -04:00
Georges-Antoine Assi
2a8fec94e6 update smart collection model 2025-07-25 16:27:10 -04:00
Georges-Antoine Assi
f7b030ba10 get backend working sorta 2025-07-22 18:10:12 -04:00
Georges-Antoine Assi
75b8181451 start work on smart collections 2025-07-22 15:49:43 -04:00
Georges-Antoine Assi
1b9ebdd83f [HOTFIX] Define virtual collections correctly 2025-02-14 17:59:36 -05:00
Georges-Antoine Assi
cd724b7d1a migrate collections over to join table 2025-01-28 23:47:09 -05:00
Georges-Antoine Assi
84c46c68eb autogen cover for collections 2025-01-27 22:20:52 -05:00
Georges-Antoine Assi
10fbead892 autogenerate cover art 2025-01-27 20:26:33 -05:00
Georges-Antoine Assi
e2c0a5f54d cleanup path covers 2025-01-27 18:43:01 -05:00
Georges-Antoine Assi
dbe4b71c7a super naive appraoch to loading virtual collections 2025-01-27 18:15:52 -05:00
Michael Manganiello
3f4a36a5ce feat: PostgreSQL compatibility
This change introduces PostgreSQL compatibility, by implementing the
following changes:

* Use `JSONB` instead of `JSON` for PostgreSQL databases. This is
  achieved by creating a custom `CustomJSON` type that uses `JSONB` on
  PostgreSQL and `JSON` on other databases, leveraging the variant
  mechanism of SQLAlchemy.
* Add `is_postgresql` function to check if the current database is
  PostgreSQL. Commonly used for migrations, but can be used to determine
  how to build queries based on the database engine.
* Add `json_array_contains_value` function to check if a JSON array
  includes a specific value. This function is needed as it's
  engine-specific.

Support for PostgreSQL is on a best-effort basis, and it relies on the
community for continued support and testing. The project's main database
is MariaDB.

Closes #667.
2024-12-31 12:36:33 -03:00
Michael Manganiello
004c0b634e fix: Make some DB columns non-nullable
This change makes some database columns non-nullable, and includes the
migration to seamlessly upgrade the schema.

It includes:
* User and Platform names
* Every boolean column
2024-07-07 11:07:27 -03:00
zurdi
59c2a51a6f added collection cover management 2024-07-03 14:31:17 +02:00
Zurdi
23e0a064ab added update collection endpoint 2024-07-02 23:34:50 +02:00
zurdi
1d6ba70080 collections get_roms endpoint added 2024-07-02 14:31:27 +02:00
Zurdi
cc9e05f668 collections migration added 2024-07-01 23:47:15 +02:00
zurdi
70200d858e Merge branch 'feature/fav_for_siblings' into feature/fav_collection 2024-06-28 16:24:04 +02:00