debug: mostrar envios recientes y total en debug-cmxc
This commit is contained in:
@@ -170,20 +170,30 @@ async def debug_cmxc(request: Request, user: dict = Depends(get_current_user), f
|
||||
if not ok:
|
||||
return JSONResponse({"error": err})
|
||||
|
||||
# Envíos del día en SQLite
|
||||
# Envíos en SQLite
|
||||
conn_sq = get_connection()
|
||||
envios = conn_sq.execute("""
|
||||
import os
|
||||
db_path = os.path.abspath(conn_sq.execute("PRAGMA database_list").fetchone()[2] if False else "rips_manager.db")
|
||||
envios_hoy = conn_sq.execute("""
|
||||
SELECT factura, status, respuesta_api, mensaje_tns, created_at
|
||||
FROM envios
|
||||
WHERE DATE(created_at) = ? AND tipo IN ('rda','preserv')
|
||||
ORDER BY id DESC
|
||||
""", (fecha,)).fetchall()
|
||||
envios_recientes = conn_sq.execute("""
|
||||
SELECT id, factura, tipo, status, created_at
|
||||
FROM envios
|
||||
ORDER BY id DESC LIMIT 10
|
||||
""").fetchall()
|
||||
total_envios = conn_sq.execute("SELECT COUNT(*) FROM envios").fetchone()[0]
|
||||
conn_sq.close()
|
||||
|
||||
return JSONResponse({
|
||||
"fecha": fecha,
|
||||
"cmxc_firebird": {"total": len(rows_fb), "rows": rows_fb},
|
||||
"envios_dia": [dict(e) for e in envios],
|
||||
"envios_hoy": [dict(e) for e in envios_hoy],
|
||||
"envios_recientes": [dict(e) for e in envios_recientes],
|
||||
"total_envios_db": total_envios,
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user