26 lines
787 B
Python
26 lines
787 B
Python
from fastapi import APIRouter, HTTPException
|
|
from services.database import get_cycle_reports, get_cycle_report, get_latest_cycle_report
|
|
|
|
router = APIRouter(prefix="/api/reports", tags=["reports"])
|
|
|
|
|
|
@router.get("/cycle/latest")
|
|
def cycle_report_latest():
|
|
"""Most recent generated cycle report."""
|
|
return {"report": get_latest_cycle_report()}
|
|
|
|
|
|
@router.get("/cycle/list")
|
|
def cycle_report_list(limit: int = 20):
|
|
"""List of cycle report summaries (no full JSON)."""
|
|
return {"reports": get_cycle_reports(limit)}
|
|
|
|
|
|
@router.get("/cycle/{run_id}")
|
|
def cycle_report_detail(run_id: str):
|
|
"""Full cycle report for a specific run_id."""
|
|
report = get_cycle_report(run_id)
|
|
if not report:
|
|
raise HTTPException(404, "Rapport de cycle introuvable")
|
|
return report
|