Add Doris Kitchen household recipe app
This commit is contained in:
33
home/doris-kitchen/app/routes/api_dashboard.py
Normal file
33
home/doris-kitchen/app/routes/api_dashboard.py
Normal file
@@ -0,0 +1,33 @@
|
||||
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:])),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user