feat: implement collection runs tracking and error acknowledgment features
This commit is contained in:
1 parent
c39364eda4
commit
34903492f6
14 files changed
+484
-21
No files matched your search
+44
@@ -57,6 +57,11 @@ def services_page():
|
||||
return _read_page("services.html")
|
||||
|
||||
|
||||
@app.get("/collecte", response_class=HTMLResponse)
|
||||
def collecte_page():
|
||||
return _read_page("collecte.html")
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
try:
|
||||
@@ -150,3 +155,42 @@ def api_resource_detail(provider: str, name: str, service_name: str):
|
||||
return queries.resource_detail(conn, provider, name, service_name)
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
@app.get("/api/collection-runs")
|
||||
def api_collection_runs(limit: int = Query(50, ge=1, le=200)):
|
||||
conn = queries.get_connection()
|
||||
try:
|
||||
return {"runs": queries.list_collection_runs(conn, limit=limit)}
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
@app.get("/api/collection-runs/alert-status")
|
||||
def api_collection_runs_alert_status():
|
||||
conn = queries.get_connection()
|
||||
try:
|
||||
return {"has_unacknowledged_errors": queries.has_unacknowledged_errors(conn)}
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
@app.get("/api/collection-runs/{run_id}/errors")
|
||||
def api_collection_run_errors(run_id: int):
|
||||
conn = queries.get_connection()
|
||||
try:
|
||||
return {"errors": queries.collection_run_errors(conn, run_id)}
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
@app.post("/api/collection-runs/{run_id}/acknowledge")
|
||||
def api_acknowledge_collection_run(run_id: int):
|
||||
conn = queries.get_connection()
|
||||
try:
|
||||
acknowledged = queries.acknowledge_collection_run(conn, run_id)
|
||||
if not acknowledged:
|
||||
raise HTTPException(status_code=404, detail="Exécution introuvable ou déjà acquittée")
|
||||
return {"status": "acknowledged"}
|
||||
finally:
|
||||
conn.close()
|
||||
Reference in new issue
Block a user