fix: add try/except to capture pipeline visual error message
This commit is contained in:
@@ -906,24 +906,15 @@ def api_xau_brief():
|
||||
@app.route("/api/pipeline/visual/<asset>", methods=["GET"])
|
||||
def pipeline_visual_asset(asset):
|
||||
"""Pipeline visual específico por ativo (USD/XAU simulado via DB)."""
|
||||
try:
|
||||
conn = _db_conn(DB_PATH)
|
||||
conn.row_factory = sqlite3.Row
|
||||
c = conn.cursor()
|
||||
|
||||
last = c.execute("SELECT * FROM pipeline_runs ORDER BY started_at DESC LIMIT 1").fetchone()
|
||||
last_5 = c.execute("SELECT * FROM pipeline_runs ORDER BY started_at DESC LIMIT 5").fetchall()
|
||||
|
||||
stats = c.execute("""
|
||||
SELECT agent, COUNT(*) as total,
|
||||
SUM(CASE WHEN status='success' THEN 1 ELSE 0 END) as ok,
|
||||
MAX(timestamp) as last_ts
|
||||
FROM executions GROUP BY agent
|
||||
""").fetchall()
|
||||
|
||||
conn.close()
|
||||
|
||||
# Busca último pipeline do ativo ou genérico
|
||||
current_state = state.get_all()
|
||||
last_run = dict(last) if last else {}
|
||||
|
||||
asset_labels = {"btc": "Bitcoin", "usd": "Dólar USD/BRL", "xau": "Ouro XAU/USD"}
|
||||
@@ -963,6 +954,9 @@ def pipeline_visual_asset(asset):
|
||||
} for r in last_5]
|
||||
|
||||
return jsonify({"nodes": nodes, "recent_runs": recent_runs, "asset": asset})
|
||||
except Exception as e:
|
||||
app.logger.error(f"Pipeline visual asset error: {e}")
|
||||
return jsonify({"error": str(e), "asset": asset}), 500
|
||||
|
||||
# ── Multi-Asset: Portfolio Live ──────────────────────────────────────────────
|
||||
@app.route("/api/portfolio/<asset>", methods=["GET"])
|
||||
|
||||
Reference in New Issue
Block a user