Add Doris Schoolhouse and clean pending homelab changes
This commit is contained in:
31
home/doris-schoolhouse/app/routes/api_dashboard.py
Normal file
31
home/doris-schoolhouse/app/routes/api_dashboard.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.services.d2l import D2LService
|
||||
from app.services.repository import get_repository
|
||||
|
||||
|
||||
router = APIRouter(prefix="/api/dashboard", tags=["dashboard"])
|
||||
repo = get_repository()
|
||||
d2l = D2LService()
|
||||
|
||||
|
||||
@router.get("/summary")
|
||||
async def dashboard_summary():
|
||||
courses = d2l.get_courses()
|
||||
assignments = repo.list_assignments()
|
||||
submissions = repo.list_submissions()
|
||||
recordings = repo.list_recordings()
|
||||
sync_runs = repo.list_sync_runs()
|
||||
return {
|
||||
"backend": repo.backend,
|
||||
"counts": {
|
||||
"courses": len(courses),
|
||||
"assignments": len(assignments),
|
||||
"submissions": len(submissions),
|
||||
"recordings": len(recordings),
|
||||
},
|
||||
"latest_sync": sync_runs[-1] if sync_runs else None,
|
||||
"recent_assignments": assignments[:8],
|
||||
"recent_submissions": submissions[:8],
|
||||
"recent_recordings": recordings[:8],
|
||||
}
|
||||
Reference in New Issue
Block a user