4 Commits

Author SHA1 Message Date
Sam Dornan
926e23d59f feat(backend): feed Steam metadata into the generated facet columns
Steam's genres, companies, developers, publishers, game modes, release
date and Metacritic score were stored by 0115 but read by nothing: the
generated columns behind roms_metadata, roms_facets and the
recommendations index never listed steam_metadata as a source. 0115
deferred that on purpose, since changing a STORED generated column
rebuilds the roms table, and asked for it to ride with a migration that
already does. 0118 and 0119 are that migration, so 0120 rebuilds the
seven affected columns with Steam appended at the lowest precedence.

Only rows carrying Steam metadata can change value, so the facet mirror
and virtual-collection membership are refreshed for those alone. Round
tripped on MariaDB 11 and PostgreSQL 16, asserting the view, facet and
membership rows at each step.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-03 09:39:13 -05:00
Georges-Antoine Assi
42ebaaec49 feat: split company metadata into publishers and developers
Metadata providers (ScreenScraper, RetroAchievements, LaunchBox,
Flashpoint, gamelist, IGDB) distinguish the publisher from the developer
of a game, but RomM amalgamated both into a single `companies` list at
ingestion, so the distinction was unrecoverable. This adds `publishers`
and `developers` as new, refined fields end to end while keeping
`companies` (the merged union) working exactly as before.

Backend:
- Handlers now emit publishers/developers alongside the unchanged
  companies list; IGDB requests the involved_companies developer/
  publisher flags to split by role.
- Migration 0112 adds generated_publishers/generated_developers columns
  on roms, projects them through the roms_metadata view, mirrors them
  into roms_facets, and adds publisher/developer virtual-collection
  types (triggers/functions rebuilt for MariaDB/MySQL + PostgreSQL).
- Filters, facets, endpoints, smart collections and the gamelist/pegasus
  exporters all carry the new fields; exporters prefer the explicit
  split and fall back to the companies heuristic for un-rescanned ROMs.

Frontend (v2):
- Shared filter store + API service, gallery filter drawer, URL
  persistence, game detail display (Developers/Publishers with a
  Companies fallback), edit dialog, smart-collection criteria, and a
  publisher/developer "group virtual collections by" option.
- Also relabels the confusing "company"->"Developer" group-by option
  to "Company" now that a proper Developer option exists.

Fixes #3518

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-27 14:44:30 -04:00
Georges-Antoine Assi
56a57da11e fix(backend): tolerate calendar-invalid gamelist dates on PostgreSQL
The gamelist branch of generated_first_release_date is gated on an
8-digits/T/6-digits regex, which does not prove the digits form a real
date. EmulationStation, ES-DE and Skyscraper write "00000000T000000" for
an unknown release date, and make_timestamp raises on it. Because the
column is STORED, that aborts the 0098 ALTER TABLE on upgrade, and any
later INSERT of such a ROM on installs already past 0098.

romm_gamelist_epoch_ms now traps the error and returns NULL, matching the
range guard the MariaDB branch already applied. 0105 replaces the
function in place for installs that have already run 0098.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 21:03:54 -04:00
Georges-Antoine Assi
dfac9dab2b perf(backend): make roms_metadata fast via generated columns
The roms_metadata VIEW re-derived its facet columns by JSON-parsing up to
eight raw provider-metadata blobs on every roms row, on every query, making
galleries, search, and sorts CPU-bound on large libraries.

Move the per-row derivation into STORED generated columns on roms (rm_*),
maintained automatically by the database engine (no application hook, no
background job). roms_metadata is redefined as a thin projection over them,
so the RomMetadata model, every handler query, and the virtual_collections
view are unchanged and inherit the speedup. Indexes on the release-date,
rating, and player-count columns back the corresponding sorts and filters.

On a 75k-row MariaDB library: release-date sort 1.15s -> 0.05s, facet-value
scan 3.35s -> 0.18s, player-count filter 0.54s -> 0.04s; virtual_collections
4.2s -> 1.3s. Generated columns match the old view byte-for-byte across all
rows except the quoted-string dates the old view silently truncated to 0.

Cross-engine correctness:
- MariaDB JSON_UNQUOTE before every numeric CAST avoids strict-mode INSERT
  truncation on quoted values.
- PostgreSQL to_timestamp()/jsonb_build_array() are only STABLE and illegal
  in generated columns; the gamelist date and age-ratings derivations run
  through IMMUTABLE wrapper functions. Gamelist dates are parsed as UTC on
  both engines so the stored value is time-zone independent.

Fixes #3768.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-19 09:19:34 -04:00