fix(monitor): only auto-monitor core studio releases

autoMonitorFuture flagged any new release, so it could auto-monitor a
newly-released live album or compilation. Gate it on is_core_release so
auto-monitoring matches the studio-only default the UI shows.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan
2026-07-12 10:42:42 +02:00
parent 33a1ed9cc4
commit 830de07997
2 changed files with 20 additions and 1 deletions
+6 -1
View File
@@ -4,6 +4,7 @@ from datetime import date, datetime
import psycopg import psycopg
from lyra_worker.browser import MbBrowser from lyra_worker.browser import MbBrowser
from lyra_worker.release_filter import is_core_release
_TRUE = {"1", "true", "yes", "on"} _TRUE = {"1", "true", "yes", "on"}
@@ -58,7 +59,11 @@ def discover(conn: psycopg.Connection, browser: MbBrowser, cfg: MonitorConfig) -
inserted = 0 inserted = 0
for artist_id, mbid, name, auto_future, monitor_from in artists: for artist_id, mbid, name, auto_future, monitor_from in artists:
for rg in browser.browse_release_groups(mbid): for rg in browser.browse_release_groups(mbid):
monitored = bool(auto_future) and _is_new(rg.first_release_date, monitor_from) monitored = (
bool(auto_future)
and _is_new(rg.first_release_date, monitor_from)
and is_core_release(rg.primary_type, rg.secondary_types)
)
with conn.cursor() as cur: with conn.cursor() as cur:
cur.execute( cur.execute(
'INSERT INTO "MonitoredRelease" (id, "watchedArtistId", "artistMbid", ' 'INSERT INTO "MonitoredRelease" (id, "watchedArtistId", "artistMbid", '
+14
View File
@@ -25,6 +25,20 @@ def test_discover_auto_monitor_future_only_flags_new(conn):
assert _monitored_map(conn) == {"rg-old": False, "rg-new": True} # only the future one is monitored assert _monitored_map(conn) == {"rg-old": False, "rg-new": True} # only the future one is monitored
def test_discover_auto_monitor_skips_non_core_releases(conn):
# autoMonitorFuture must only auto-flag *core* studio releases; a new live album or
# compilation is recorded (unmonitored) but never auto-monitored.
insert_watched_artist(conn, mbid="a1", name="X", auto_monitor_future=True)
releases = [
ReleaseGroupInfo("rg-studio", "Studio", "Album", (), "2999-01-01"),
ReleaseGroupInfo("rg-live", "Live", "Album", ("Live",), "2999-02-01"),
ReleaseGroupInfo("rg-comp", "Best Of", "Album", ("Compilation",), "2999-03-01"),
]
browser = FakeMbBrowser(releases={"a1": releases})
discover(conn, browser, MonitorConfig(enabled=True))
assert _monitored_map(conn) == {"rg-studio": True, "rg-live": False, "rg-comp": False}
def test_discover_default_off_monitors_nothing(conn): def test_discover_default_off_monitors_nothing(conn):
insert_watched_artist(conn, mbid="a1", name="X", auto_monitor_future=False) insert_watched_artist(conn, mbid="a1", name="X", auto_monitor_future=False)
browser = FakeMbBrowser(releases={"a1": _releases()}) browser = FakeMbBrowser(releases={"a1": _releases()})