From 80109976bfdcdc9391abb0908ecee30ee840a4a6 Mon Sep 17 00:00:00 2001 From: derekc Date: Sat, 28 Feb 2026 17:21:22 -0800 Subject: [PATCH] Reset child strikes to 0 when starting a new day session Co-Authored-By: Claude Sonnet 4.6 --- backend/app/routers/sessions.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/app/routers/sessions.py b/backend/app/routers/sessions.py index a823102..946ebb3 100644 --- a/backend/app/routers/sessions.py +++ b/backend/app/routers/sessions.py @@ -95,9 +95,15 @@ async def start_session( child_result = await db.execute( select(Child).where(Child.id == body.child_id, Child.user_id == current_user.id) ) - if not child_result.scalar_one_or_none(): + child = child_result.scalar_one_or_none() + if not child: raise HTTPException(status_code=404, detail="Child not found") + # Reset strikes at the start of each new day + if child.strikes != 0: + child.strikes = 0 + await manager.broadcast(body.child_id, {"event": "strikes_update", "strikes": 0}) + session_date = body.session_date or date.today() # Deactivate any existing active session for this child today