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:
@@ -4,6 +4,7 @@ from datetime import date, datetime
|
||||
import psycopg
|
||||
|
||||
from lyra_worker.browser import MbBrowser
|
||||
from lyra_worker.release_filter import is_core_release
|
||||
|
||||
_TRUE = {"1", "true", "yes", "on"}
|
||||
|
||||
@@ -58,7 +59,11 @@ def discover(conn: psycopg.Connection, browser: MbBrowser, cfg: MonitorConfig) -
|
||||
inserted = 0
|
||||
for artist_id, mbid, name, auto_future, monitor_from in artists:
|
||||
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:
|
||||
cur.execute(
|
||||
'INSERT INTO "MonitoredRelease" (id, "watchedArtistId", "artistMbid", '
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
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):
|
||||
insert_watched_artist(conn, mbid="a1", name="X", auto_monitor_future=False)
|
||||
browser = FakeMbBrowser(releases={"a1": _releases()})
|
||||
|
||||
Reference in New Issue
Block a user