correcion de fallo al recuperar feeds
This commit is contained in:
parent
2cd6cdfe3c
commit
0433b3b004
1 changed files with 6 additions and 2 deletions
8
app.py
8
app.py
|
|
@ -365,10 +365,12 @@ def restore_feeds():
|
|||
try:
|
||||
activo_val = str(row.get("activo", "")).strip().lower()
|
||||
activo = activo_val in ["1", "true", "t", "yes", "on"]
|
||||
|
||||
# --- ESTA ES LA PARTE CORREGIDA ---
|
||||
cursor.execute(
|
||||
"""
|
||||
INSERT INTO feeds (id, nombre, descripcion, url, categoria_id, pais_id, idioma, activo, fallos)
|
||||
VALUES (%(id)s, %(nombre)s, %(descripcion)s, %(url)s, %(categoria_id)s, %(pais_id)s, %(idoma)s, %(activo)s, %(fallos)s)
|
||||
VALUES (%(id)s, %(nombre)s, %(descripcion)s, %(url)s, %(categoria_id)s, %(pais_id)s, %(idioma)s, %(activo)s, %(fallos)s)
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
nombre = EXCLUDED.nombre, descripcion = EXCLUDED.descripcion, url = EXCLUDED.url,
|
||||
categoria_id = EXCLUDED.categoria_id, pais_id = EXCLUDED.pais_id, idioma = EXCLUDED.idioma,
|
||||
|
|
@ -377,7 +379,8 @@ def restore_feeds():
|
|||
{
|
||||
"id": int(row.get("id")), "nombre": row.get("nombre"), "descripcion": row.get("descripcion") or "",
|
||||
"url": row.get("url"), "categoria_id": int(row["categoria_id"]) if row.get("categoria_id") else None,
|
||||
"pais_id": int(row["pais_id"]) if row.get("pais_id") else None, "idioma": row.get("idioma") or None,
|
||||
"pais_id": int(row["pais_id"]) if row.get("pais_id") else None,
|
||||
"idioma": row.get("idioma") or None, # La clave aquí es 'idioma'
|
||||
"activo": activo, "fallos": int(row.get("fallos", 0)),
|
||||
}
|
||||
)
|
||||
|
|
@ -385,6 +388,7 @@ def restore_feeds():
|
|||
except Exception as e:
|
||||
n_err += 1
|
||||
app.logger.error(f"Error procesando fila del CSV: {row} - Error: {e}")
|
||||
|
||||
flash(f"Restauración completada. Feeds procesados: {n_ok}. Errores: {n_err}.", "success" if n_err == 0 else "warning")
|
||||
except Exception as e:
|
||||
app.logger.error(f"Error al restaurar feeds desde CSV: {e}", exc_info=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue