Update stats
Build Backend / build (push) Successful in 1m59s
Build Frontend / build (push) Failing after 2m55s

This commit is contained in:
2026-05-31 09:23:50 +02:00
parent 7d9c22d5d3
commit 7061e78305
9 changed files with 173 additions and 17 deletions
+5 -1
View File
@@ -3,7 +3,7 @@ from typing import List, Optional
from fastapi import APIRouter, Depends, Query
from sqlmodel.ext.asyncio.session import AsyncSession
from app.database import get_session
from app.crud import get_sessions
from app.crud import get_sessions, get_all_time_stats
from app.schemas import DailySummaryResponse, TimetableResponse, WakeupBedtimeResponse, SummaryResponse
from app.utils.time_utils import get_day_night_splits
@@ -112,9 +112,13 @@ async def get_summary(
num_days = (to_date.date() - from_date.date()).days + 1
avg_sleeps_per_day = total_sleeps / num_days if num_days > 0 else 0.0
total_sleeps_all_time, avg_sleeps_per_day_all_time = await get_all_time_stats(session)
return {
"total_sleeps": total_sleeps,
"avg_sleeps_per_day": avg_sleeps_per_day,
"total_sleeps_all_time": total_sleeps_all_time,
"avg_sleeps_per_day_all_time": avg_sleeps_per_day_all_time,
}