feat(worker): discovery chunk_size + seed-count in result (retire max_seeds)
Reconciled the pre-existing test_config_from_config_parses_and_defaults test in test_discovery.py, which referenced max_seeds/maxSeeds and would otherwise have broken.
This commit is contained in:
@@ -13,7 +13,7 @@ _TRUE = {"1", "true", "yes", "on"}
|
||||
class DiscoveryConfig:
|
||||
enabled: bool = False
|
||||
interval_hours: int = 168
|
||||
max_seeds: int = 50
|
||||
chunk_size: int = 5
|
||||
similar_per_seed: int = 20
|
||||
albums_per_artist: int = 1
|
||||
min_score: float = 0.0
|
||||
@@ -35,7 +35,7 @@ class DiscoveryConfig:
|
||||
return cls(
|
||||
enabled=str(config.get("discover.enabled", "")).strip().lower() in _TRUE,
|
||||
interval_hours=_int("discover.intervalHours", 168),
|
||||
max_seeds=_int("discover.maxSeeds", 50),
|
||||
chunk_size=_int("discover.chunkSize", 5),
|
||||
similar_per_seed=_int("discover.similarPerSeed", 20),
|
||||
albums_per_artist=_int("discover.albumsPerArtist", 1),
|
||||
min_score=_float("discover.minScore", 0.0),
|
||||
@@ -46,6 +46,7 @@ class DiscoveryConfig:
|
||||
class DiscoveryResult:
|
||||
artists: int
|
||||
albums: int
|
||||
seeds: int = 0
|
||||
|
||||
|
||||
def _healthy_sources(sources):
|
||||
@@ -68,7 +69,7 @@ def _seed_artists(conn: psycopg.Connection, cfg: DiscoveryConfig):
|
||||
'WHERE "lastDiscoveredAt" IS NULL '
|
||||
' OR "lastDiscoveredAt" < now() - make_interval(hours => %s) '
|
||||
'ORDER BY "lastDiscoveredAt" ASC NULLS FIRST LIMIT %s',
|
||||
(cfg.interval_hours, cfg.max_seeds),
|
||||
(cfg.interval_hours, cfg.chunk_size),
|
||||
)
|
||||
return cur.fetchall()
|
||||
|
||||
@@ -190,4 +191,4 @@ def run_discovery(conn: psycopg.Connection, sources: list[SimilaritySource],
|
||||
cur.execute('UPDATE "WatchedArtist" SET "lastDiscoveredAt" = now() WHERE mbid = %s',
|
||||
(seed_mbid,))
|
||||
conn.commit()
|
||||
return DiscoveryResult(artists=artists, albums=albums)
|
||||
return DiscoveryResult(artists=artists, albums=albums, seeds=len(seeds))
|
||||
|
||||
Reference in New Issue
Block a user