Reset child strikes to 0 when starting a new day session
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -95,9 +95,15 @@ async def start_session(
|
|||||||
child_result = await db.execute(
|
child_result = await db.execute(
|
||||||
select(Child).where(Child.id == body.child_id, Child.user_id == current_user.id)
|
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")
|
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()
|
session_date = body.session_date or date.today()
|
||||||
|
|
||||||
# Deactivate any existing active session for this child today
|
# Deactivate any existing active session for this child today
|
||||||
|
|||||||
Reference in New Issue
Block a user