feat: live-ticking In Session timer using active session start times
SidebarStatsBar now computes active session elapsed time client-side from started_at timestamps, ticking every 60s. Backend only returns completed session minutes to avoid double-counting. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -65,16 +65,17 @@ async def get_sidebar_stats(
|
||||
)
|
||||
active_count = active_result.scalar() or 0
|
||||
|
||||
# --- Total session minutes today ---
|
||||
# --- Completed session minutes today (active session time computed client-side) ---
|
||||
duration_expr = func.extract(
|
||||
"epoch",
|
||||
func.coalesce(Session.completed_at, now_utc) - Session.started_at,
|
||||
Session.completed_at - Session.started_at,
|
||||
) / 60.0
|
||||
duration_result = await db.execute(
|
||||
select(func.coalesce(func.sum(duration_expr), 0)).where(
|
||||
and_(
|
||||
user_filter,
|
||||
Session.started_at.isnot(None),
|
||||
Session.completed_at.isnot(None),
|
||||
Session.started_at >= today_start_utc,
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user