From cf29d171839c84363dac8ef0bf1e4f51a1b62b8e Mon Sep 17 00:00:00 2001 From: chelsea Date: Thu, 19 Feb 2026 20:40:31 -0600 Subject: [PATCH] Also suppress nags for skipped medications --- core/adaptive_meds.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/adaptive_meds.py b/core/adaptive_meds.py index cdb71d0..a7c09b6 100644 --- a/core/adaptive_meds.py +++ b/core/adaptive_meds.py @@ -297,13 +297,12 @@ def should_send_nag( if time_since_last_nag < nag_interval: return False, f"Too soon ({int(time_since_last_nag)} < {nag_interval} min)" - # Check if this specific dose was already taken today + # Check if this specific dose was already taken or skipped today logs = postgres.select( "med_logs", { "medication_id": med_id, "user_uuid": user_uuid, - "action": "taken", }, ) @@ -330,6 +329,10 @@ def should_send_nag( # Filter to today's logs and check for this specific dose for log in logs: + action = log.get("action") + if action not in ("taken", "skipped"): + continue + created_at = log.get("created_at") if not created_at: continue @@ -340,7 +343,7 @@ def should_send_nag( if log_scheduled_time: log_scheduled_time = _normalize_time(log_scheduled_time) if log_scheduled_time == scheduled_time: - return False, "Already taken today" + return False, f"Already {action} today" else: if scheduled_time and created_at: log_hour = created_at.hour @@ -353,7 +356,7 @@ def should_send_nag( (log_hour * 60 + log_min) - (sched_hour * 60 + sched_min) ) if diff_minutes <= proximity_window: - return False, "Already taken today" + return False, f"Already {action} today" return True, "Time to nag"