feat(backend): demo scheduler on the virtual clock — doses, missed, check-ins, scales, silence
CI / ruff · pytest (pull_request) Successful in 1m3s
CI / ruff · pytest (pull_request) Successful in 1m3s
- app/scheduler/demo.py: run_until(now) replays due and fresh events in time order: dose rows + med_reminder, missed after 2 h without an answer → monitoring, daily_checkin, scale_due by the config/modules.yaml schedules, daily monitoring pass (silence, missed doses) → reach_out/scale_due - idempotent via scheduler_events (unique token+key); stale events are not sent; no contact without consent or during an open crisis - config/scheduler.yaml: times and windows; runs while the questionnaire release is off - POST /demo/clock/advance replays the scheduler up to the new time Refs #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+3
-1
@@ -25,6 +25,7 @@ from app.api.schemas import (
|
||||
from app.core import clock
|
||||
from app.dialog.contracts import get_engine
|
||||
from app.integrations.base import MemoryOutbox, integrations
|
||||
from app.scheduler import jobs as scheduler
|
||||
|
||||
router = APIRouter(prefix="/api/v1")
|
||||
router.include_router(questionnaire_router)
|
||||
@@ -99,8 +100,9 @@ async def get_clock() -> ClockOut:
|
||||
|
||||
@router.post("/demo/clock/advance", response_model=ClockOut, tags=["demo"])
|
||||
async def advance_clock(body: ClockAdvanceIn) -> ClockOut:
|
||||
"""Moves the virtual clock; #13 makes the scheduler replay all events up to the new time."""
|
||||
"""Moves the virtual clock and replays the scheduler up to the new time (#13)."""
|
||||
clock.advance(days=body.days, hours=body.hours)
|
||||
await scheduler.run_until_now()
|
||||
return _clock_out()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user