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:
parent
ca45697207
commit
891285a572
1 changed files with 11 additions and 12 deletions
|
|
@ -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."""
|
"""Met à jour les champs d'enrichissement d'un band."""
|
||||||
sql = """
|
sql = """
|
||||||
UPDATE bands SET
|
UPDATE bands SET
|
||||||
status = COALESCE($2, status),
|
status = COALESCE(%s, status),
|
||||||
genre = COALESCE($3, genre),
|
genre = COALESCE(%s, genre),
|
||||||
themes = COALESCE($4, themes),
|
themes = COALESCE(%s, themes),
|
||||||
formed_year = COALESCE($5, formed_year),
|
formed_year = COALESCE(%s, formed_year),
|
||||||
data = data || $6::jsonb,
|
data = data || %s::jsonb,
|
||||||
enriched = true,
|
enriched = true,
|
||||||
crawled_at = $7,
|
crawled_at = %s,
|
||||||
crawled_hash = $8,
|
crawled_hash = %s,
|
||||||
ma_created_at = COALESCE($9, ma_created_at),
|
ma_created_at = COALESCE(%s, ma_created_at),
|
||||||
ma_modified_at= COALESCE($10, ma_modified_at)
|
ma_modified_at= COALESCE(%s, ma_modified_at)
|
||||||
WHERE ma_id = $1
|
WHERE ma_id = %s
|
||||||
"""
|
"""
|
||||||
ts = now_utc()
|
ts = now_utc()
|
||||||
with get_conn() as conn:
|
with get_conn() as conn:
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
import json
|
|
||||||
cur.execute(sql, (
|
cur.execute(sql, (
|
||||||
ma_id,
|
|
||||||
data.get("status"),
|
data.get("status"),
|
||||||
data.get("genre"),
|
data.get("genre"),
|
||||||
data.get("themes"),
|
data.get("themes"),
|
||||||
|
|
@ -130,6 +128,7 @@ def upsert_band_enriched(ma_id: int, data: Dict[str, Any], html_hash: str) -> bo
|
||||||
html_hash,
|
html_hash,
|
||||||
data.get("ma_created_at"),
|
data.get("ma_created_at"),
|
||||||
data.get("ma_modified_at"),
|
data.get("ma_modified_at"),
|
||||||
|
ma_id,
|
||||||
))
|
))
|
||||||
return cur.rowcount > 0
|
return cur.rowcount > 0
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue