muchas cosas
This commit is contained in:
parent
e3936fd4cf
commit
eff656adea
20 changed files with 697 additions and 51 deletions
|
|
@ -259,7 +259,7 @@ def fetch_traducciones_info_batch(conn, tr_ids: List[int]) -> Dict[int, Dict[str
|
|||
"traduccion_id": tr_id,
|
||||
"noticia_id": row["noticia_id"],
|
||||
"fecha": row["fecha"],
|
||||
"titulo_evento": row["titulo_evento"] or "",
|
||||
"titulo_evento": (row["titulo_evento"] or "")[:255],
|
||||
}
|
||||
return result
|
||||
|
||||
|
|
|
|||
|
|
@ -583,7 +583,7 @@ def fetch_pending_translations(conn):
|
|||
WHERE t.lang_to = %s
|
||||
AND (t.titulo_trad IS NULL OR t.resumen_trad IS NULL)
|
||||
AND (t.locked_at IS NULL OR t.locked_at < NOW() - INTERVAL '10 minutes')
|
||||
ORDER BY n.fecha DESC
|
||||
ORDER BY n.fecha ASC
|
||||
LIMIT %s
|
||||
FOR UPDATE SKIP LOCKED
|
||||
""",
|
||||
|
|
@ -593,7 +593,23 @@ def fetch_pending_translations(conn):
|
|||
rows = cursor.fetchall()
|
||||
if rows:
|
||||
LOG.info(f"Found {len(rows)} pending translations for {lang}")
|
||||
start_ts = time.time()
|
||||
process_batch(conn, rows)
|
||||
elapsed_ms = int((time.time() - start_ts) * 1000)
|
||||
try:
|
||||
metrics_cur = conn.cursor()
|
||||
metrics_cur.execute(
|
||||
"""
|
||||
INSERT INTO translation_stats (lang_to, items_translated, elapsed_ms, hostname)
|
||||
VALUES (%s, %s, %s, %s)
|
||||
""",
|
||||
(lang, len(rows), elapsed_ms, worker_id),
|
||||
)
|
||||
conn.commit()
|
||||
metrics_cur.close()
|
||||
except Exception as e:
|
||||
LOG.error(f"Error recording translation stats: {e}")
|
||||
conn.rollback()
|
||||
total_found += len(rows)
|
||||
|
||||
cursor.close()
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ def create_translation_jobs(conn):
|
|||
SELECT 1 FROM traducciones t
|
||||
WHERE t.noticia_id = n.id AND t.lang_to = %s
|
||||
)
|
||||
ORDER BY n.fecha DESC
|
||||
ORDER BY n.fecha ASC
|
||||
LIMIT %s
|
||||
ON CONFLICT (noticia_id, lang_to) DO NOTHING
|
||||
RETURNING noticia_id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue