From 288e447d3e3e00afdd50c1dab0460317c5d02fbb Mon Sep 17 00:00:00 2001 From: chelsea Date: Thu, 19 Feb 2026 13:17:51 -0600 Subject: [PATCH] =?UTF-8?q?Fix=20nagging=20for=20doses=20not=20yet=20due?= =?UTF-8?q?=20=E2=80=94=20check=20scheduled=20time=20before=20nagging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit should_send_nag() was iterating all pending schedules for today without verifying the scheduled time had actually passed. A dose scheduled for 18:00 would get nagged at 13:15. Add an early return when current_time is before the scheduled dose time. Co-Authored-By: Claude Opus 4.6 --- core/adaptive_meds.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/adaptive_meds.py b/core/adaptive_meds.py index a15af69..0b5f646 100644 --- a/core/adaptive_meds.py +++ b/core/adaptive_meds.py @@ -245,6 +245,13 @@ def should_send_nag( """ scheduled_time = _normalize_time(scheduled_time) + # Don't nag for doses that aren't due yet + if scheduled_time: + sched_hour, sched_min = int(scheduled_time[:2]), int(scheduled_time[3:5]) + sched_as_time = time(sched_hour, sched_min) + if current_time.time() < sched_as_time: + return False, "Not yet due" + settings = get_adaptive_settings(user_uuid) if not settings: return False, "No settings"