34 lines
1007 B
Python
34 lines
1007 B
Python
from fastapi import APIRouter
|
|
|
|
from app.services.repository import repo
|
|
|
|
|
|
router = APIRouter(prefix="/api", tags=["dashboard"])
|
|
|
|
|
|
@router.get("/health")
|
|
async def health():
|
|
return {"status": "ok", "backend": repo.backend}
|
|
|
|
|
|
@router.get("/dashboard/summary")
|
|
async def summary():
|
|
profile = repo.get_profile()
|
|
suggestions = repo.list_suggestions()
|
|
plans = repo.list_meal_plans()
|
|
counts = {
|
|
"suggested": sum(1 for item in suggestions if item.get("status") == "suggested"),
|
|
"approved": sum(1 for item in suggestions if item.get("status") == "approved"),
|
|
"saved": sum(1 for item in suggestions if item.get("status") == "saved"),
|
|
"rejected": sum(1 for item in suggestions if item.get("status") == "rejected"),
|
|
"plans": len(plans),
|
|
}
|
|
return {
|
|
"backend": repo.backend,
|
|
"profile": profile,
|
|
"counts": counts,
|
|
"recent_suggestions": repo.recent_suggestions(),
|
|
"recent_plans": list(reversed(plans[-4:])),
|
|
}
|
|
|