Update stats
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user