- schema: disc_cache (release_id→title/artist/thumb/weight); build_disc_cache.py populates it from the full Discogs dump on ultra (30,694 stocked releases). - app/mirror.py: enrich() now reads RecordGod's OWN disc_cache via the main DB — no live discogs_full / dealgod-DB dependency. DealGod reached only via API key. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
23 lines
848 B
Python
23 lines
848 B
Python
from sqlalchemy import text
|
|
|
|
from .db import SessionLocal
|
|
|
|
# Enrichment from RecordGod's OWN cached catalog (disc_cache) — self-contained, no live
|
|
# dependency on the full Discogs dump or dealgod's DB. Populate via build_disc_cache.py.
|
|
# DealGod is reached only via its API (for market value), never its database.
|
|
|
|
|
|
async def enrich(ids):
|
|
"""release_id(s) → {id: {title, artist, thumb, weight}}. Best-effort."""
|
|
ids = [i for i in set(ids) if i is not None]
|
|
if not ids:
|
|
return {}
|
|
try:
|
|
async with SessionLocal() as s:
|
|
rows = await s.execute(text(
|
|
"SELECT release_id AS id, title, artist, thumb, weight "
|
|
"FROM disc_cache WHERE release_id = ANY(:ids)"), {"ids": ids})
|
|
return {r["id"]: dict(r) for r in rows.mappings()}
|
|
except Exception:
|
|
return {}
|