Fix off-day med reminders and add medication editing

Scheduler: check_nagging() now calls _is_med_due_today() before creating
on-demand schedules or processing existing ones — prevents nagging
for specific_days / every_n_days meds on days they are not scheduled.

Web client: add Edit button (pencil icon) on each medication card linking
to /dashboard/medications/[id]/edit — new page pre-populates the full
form (name, dosage, unit, frequency, times, days, interval, notes)
and submits PUT /api/medications/:id on save.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-19 16:49:12 -06:00
parent bebc609091
commit d45929ddc0
3 changed files with 284 additions and 8 deletions

View File

@@ -317,6 +317,10 @@ def check_nagging():
now = _user_now_for(user_uuid)
today = now.date()
# Skip nagging if medication is not due today
if not _is_med_due_today(med, today):
continue
# Get today's schedules
try:
schedules = postgres.select(
@@ -333,8 +337,10 @@ def check_nagging():
# Table may not exist yet
continue
# If no schedules exist, try to create them
# If no schedules exist, try to create them — but only if med is due today
if not schedules:
if not _is_med_due_today(med, today):
continue
logger.info(f"No schedules found for medication {med_id}, attempting to create")
times = med.get("times", [])
if times: