fix(discover): hide stale singles + replace album set on re-derive
- Client filters the row's album thumbnails to full albums only (hides singles/EPs left over from pre-albums-only sweeps). - Worker: re-deriving an artist deletes its pending album suggestions that are no longer picks (stale singles / now-owned), keeping wanted/dismissed rows, so the suggestion set self-cleans instead of accumulating. worker 246, web 189 tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ from lyra_worker.adapters.fakes import FakeMbBrowser, FakeSimilaritySource
|
||||
from lyra_worker.browser import ReleaseGroupInfo
|
||||
from lyra_worker.discovery import DiscoveryConfig, run_discovery
|
||||
from lyra_worker.similarity.base import SimilarArtist
|
||||
from tests.conftest import insert_monitored_release, insert_watched_artist
|
||||
from tests.conftest import insert_discovery_suggestion, insert_monitored_release, insert_watched_artist
|
||||
|
||||
|
||||
def _album_rows(conn):
|
||||
@@ -92,6 +92,34 @@ def test_popular_matches_by_title_when_lastfm_mbid_missing_and_skips_owned(conn)
|
||||
assert _reasons(conn) == {"rg-new": "newest", "rg-match": "popular"}
|
||||
|
||||
|
||||
def test_rederiving_replaces_stale_pending_album_suggestions(conn):
|
||||
insert_watched_artist(conn, mbid="s1", name="Seed")
|
||||
# a stale pending album suggestion for c1 that is no longer a pick (e.g. an old single)
|
||||
insert_discovery_suggestion(conn, kind="album", artist_mbid="c1", rg_mbid="rg-old-single",
|
||||
album="Old Single", status="pending")
|
||||
src = FakeSimilaritySource(similar={"s1": [SimilarArtist("c1", "Cand", 0.9)]})
|
||||
browser = FakeMbBrowser(releases={"c1": [
|
||||
ReleaseGroupInfo("rg-new", "New Album", "Album", (), "2022-01-01"),
|
||||
]})
|
||||
run_discovery(conn, [src], browser, DiscoveryConfig(albums_per_artist=1))
|
||||
# the stale single is gone; only the freshly-derived album remains
|
||||
assert [r[1] for r in _album_rows(conn)] == ["rg-new"]
|
||||
|
||||
|
||||
def test_rederiving_keeps_wanted_album_suggestions(conn):
|
||||
insert_watched_artist(conn, mbid="s1", name="Seed")
|
||||
insert_discovery_suggestion(conn, kind="album", artist_mbid="c1", rg_mbid="rg-wanted",
|
||||
album="Wanted One", status="wanted")
|
||||
src = FakeSimilaritySource(similar={"s1": [SimilarArtist("c1", "Cand", 0.9)]})
|
||||
browser = FakeMbBrowser(releases={"c1": [
|
||||
ReleaseGroupInfo("rg-new", "New Album", "Album", (), "2022-01-01"),
|
||||
]})
|
||||
run_discovery(conn, [src], browser, DiscoveryConfig(albums_per_artist=1))
|
||||
with conn.cursor() as cur: # wanted row untouched (only pending stale rows are replaced)
|
||||
cur.execute('SELECT count(*) FROM "DiscoverySuggestion" WHERE "rgMbid" = %s AND status = \'wanted\'', ("rg-wanted",))
|
||||
assert cur.fetchone()[0] == 1
|
||||
|
||||
|
||||
def test_no_popularity_provider_yields_newest_only(conn):
|
||||
insert_watched_artist(conn, mbid="s1", name="Seed")
|
||||
src = FakeSimilaritySource(similar={"s1": [SimilarArtist("c1", "Cand", 0.9)]})
|
||||
|
||||
Reference in New Issue
Block a user