mirror of
https://github.com/rommapp/romm.git
synced 2026-12-04 12:52:19 +01:00
* fix(siblings): group versions by connected component everywhere The game page's siblings matched on any shared provider id, while the gallery's group_by_meta_id window partitioned on the first non-null id in a fixed provider order. A version matched by IGDB and ScreenScraper and one matched by ScreenScraper alone were siblings on the game page but two gallery cards. The recommendation surfaces didn't group at all: the cold-start row ranks by rating, which every version shares, so one game filled it. rom_sibling_groups now stores each ROM's connected component over rom_identity_keys, kept in step by add_rom/update_rom/delete_rom and rebuilt after a scan. The sibling_roms view, the gallery window and the recommendations all read it: the feed and similar games collapse each game to one entry, exclude the other versions of a played game, and show the version the grouped gallery shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(siblings): answer the Versions filter from rom_sibling_groups Only a ROM with another version has a group row, so "has versions" is a primary-key probe rather than an EXISTS over the sibling_roms self-join. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(siblings): break representative ties by id; restore Versions filter Versions often share a filename stem and region, and without a final key the version that represents a group could change between queries. The "Versions" filter goes back to EXISTS over sibling_roms: measured on a 100k-ROM library it takes the same time as the direct group-row probe (107 ms each), since the view merges into the query. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(migrations): renumber rom_sibling_groups to 0158 after master's 0157 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(recommendations): address Greptile review on sibling grouping - Swap each recommendation to its visible representative before the visibility cut, so a game whose top-ranked version is hidden shows through a visible one instead of disappearing. - Read candidates in batches until enough distinct games remain, so a game with more versions than one overfetch batch no longer crowds out the rest of the feed; the cold-start query pages with an id tiebreak. - Shorten the 0158 migration and RomSiblingGroup docstrings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(recommendations): use the shared auth helpers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pr-ready: code-review Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pr-ready: simplify Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pr-ready: prose Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pr-ready: prose (code-review fixes) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(recommendations): hide only the hidden version, as the gallery does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(siblings): regroup only on identity changes and scope the post-scan repair add_rom skips the regroup when the merge changed no identity column. The post-scan repair regroups the scanned ROMs for a ROM-scoped scan and rebuilds only the scanned platforms otherwise, since no group spans two platforms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
835 B
Python
29 lines
835 B
Python
from utils.sibling_groups import sibling_groups
|
|
|
|
|
|
def test_roms_sharing_no_key_are_left_out():
|
|
assert sibling_groups([(1, "a"), (2, "b")]) == {}
|
|
|
|
|
|
def test_a_shared_key_groups_under_the_lowest_id():
|
|
assert sibling_groups([(7, "a"), (3, "a")]) == {3: 3, 7: 3}
|
|
|
|
|
|
def test_a_chain_of_different_keys_is_one_group():
|
|
"""1 and 3 share nothing, but each shares a key with 2."""
|
|
rows = [(1, "igdb"), (2, "igdb"), (2, "ss"), (3, "ss")]
|
|
|
|
assert sibling_groups(rows) == {1: 1, 2: 1, 3: 1}
|
|
|
|
|
|
def test_merging_two_groups_keeps_the_lower_root():
|
|
rows = [(5, "a"), (6, "a"), (2, "b"), (9, "b"), (9, "c"), (6, "c")]
|
|
|
|
assert set(sibling_groups(rows).values()) == {2}
|
|
|
|
|
|
def test_separate_groups_stay_separate():
|
|
rows = [(1, "a"), (2, "a"), (3, "b"), (4, "b")]
|
|
|
|
assert sibling_groups(rows) == {1: 1, 2: 1, 3: 3, 4: 3}
|