Also suppress nags for skipped medications

This commit is contained in:
2026-02-19 20:40:31 -06:00
parent cc1aace73d
commit cf29d17183

View File

@@ -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"