fix(crawler): upsert_band_enriched $1→%s (psycopg2 ne supporte pas la syntaxe PG native)

Bug latent : la fonction n'était jamais appelée avant car get_bands_to_enrich
retournait 0. Exposé dès le premier run réel avec la nouvelle priority queue.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Nicolas Fryder 2026-06-30 21:28:03 +02:00
parent ca45697207
commit 891285a572

View file

@ -103,24 +103,22 @@ def upsert_band_enriched(ma_id: int, data: Dict[str, Any], html_hash: str) -> bo
"""Met à jour les champs d'enrichissement d'un band."""
sql = """
UPDATE bands SET
status = COALESCE($2, status),
genre = COALESCE($3, genre),
themes = COALESCE($4, themes),
formed_year = COALESCE($5, formed_year),
data = data || $6::jsonb,
status = COALESCE(%s, status),
genre = COALESCE(%s, genre),
themes = COALESCE(%s, themes),
formed_year = COALESCE(%s, formed_year),
data = data || %s::jsonb,
enriched = true,
crawled_at = $7,
crawled_hash = $8,
ma_created_at = COALESCE($9, ma_created_at),
ma_modified_at= COALESCE($10, ma_modified_at)
WHERE ma_id = $1
crawled_at = %s,
crawled_hash = %s,
ma_created_at = COALESCE(%s, ma_created_at),
ma_modified_at= COALESCE(%s, ma_modified_at)
WHERE ma_id = %s
"""
ts = now_utc()
with get_conn() as conn:
with conn.cursor() as cur:
import json
cur.execute(sql, (
ma_id,
data.get("status"),
data.get("genre"),
data.get("themes"),
@ -130,6 +128,7 @@ def upsert_band_enriched(ma_id: int, data: Dict[str, Any], html_hash: str) -> bo
html_hash,
data.get("ma_created_at"),
data.get("ma_modified_at"),
ma_id,
))
return cur.rowcount > 0