fix(discover): drop suggestions for non-artists (no core discography)

ListenBrainz surfaces producers/session players/band members (Max Martin,
Dominic Howard) that co-occur in listens but have no releases of their own —
they showed as bare rows with an empty page. _derive_albums now drops a
surfaced artist (deletes their pending suggestion) when their MB discography
has no core release-group (Album/Single/EP, no secondary type), catching both
empty discographies and soundtrack/production-only credits, while keeping real
singles/EP-only artists. On browse failure the suggestion is kept.

Test fake browser gains default_core so scoring tests keep surfacing candidates.
worker 249 tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan
2026-07-15 00:38:56 +02:00
parent 9915bfbda2
commit 4a768b7122
4 changed files with 70 additions and 24 deletions
+29
View File
@@ -12,6 +12,13 @@ def _album_rows(conn):
return cur.fetchall()
def _artist_rows(conn):
with conn.cursor() as cur:
cur.execute("SELECT \"artistMbid\" FROM \"DiscoverySuggestion\" "
"WHERE kind = 'artist' AND status = 'pending' ORDER BY \"artistMbid\"")
return cur.fetchall()
def _reasons(conn):
with conn.cursor() as cur:
cur.execute('SELECT "rgMbid", "albumReason" FROM "DiscoverySuggestion" '
@@ -120,6 +127,28 @@ def test_rederiving_keeps_wanted_album_suggestions(conn):
assert cur.fetchone()[0] == 1
def test_drops_artist_with_no_core_discography(conn):
# Two candidates: one real (has a core album), one a "producer" whose only release is a
# secondary-typed soundtrack (like Max Martin's & Juliet) — the latter must be dropped.
insert_watched_artist(conn, mbid="s1", name="Seed")
src = FakeSimilaritySource(similar={"s1": [
SimilarArtist("real", "Real Artist", 0.9), SimilarArtist("producer", "Producer", 0.8)]})
browser = FakeMbBrowser(releases={
"real": [ReleaseGroupInfo("rg-r", "Record", "Album", (), "2020-01-01")],
"producer": [ReleaseGroupInfo("rg-st", "A Musical", "Album", ("Soundtrack",), "2019-01-01")],
})
run_discovery(conn, [src], browser, DiscoveryConfig(albums_per_artist=1))
assert [r[0] for r in _artist_rows(conn)] == ["real"] # producer dropped
def test_drops_artist_with_empty_discography(conn):
insert_watched_artist(conn, mbid="s1", name="Seed")
src = FakeSimilaritySource(similar={"s1": [SimilarArtist("member", "Band Member", 0.9)]})
browser = FakeMbBrowser(releases={"member": []}) # no release groups at all
run_discovery(conn, [src], browser, DiscoveryConfig(albums_per_artist=1))
assert _artist_rows(conn) == []
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)]})