From f295fd12e6ffc8a7c023a83b3ac1223664255e90 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Thu, 3 Sep 2026 00:45:53 +0000 Subject: Abandon recurring occurrences superseded by their next iteration A weekly task not done before the next one lands is stale, not still owed. The scheduler already created the successor regardless of completion (deliberately, so skipping one doesn't stall the series), but nothing retired the occurrence it replaced -- so every skipped occurrence stayed open forever as a permanent overdue item. Live: "Bills" and "Bones's meds" each sat in the list twice. AdvanceDueRecurringTasks now marks the superseded occurrence abandoned when it creates the successor. A separate flag rather than `completed`, because these were never done and crediting them would corrupt completion history. All four open-task queries filter it out; migration 030 adds the column and backfills the occurrences already superseded (exactly the 2 above, verified against production before deploying). Supersedes the earlier view-level collapse (10f9fcd, reverted in 96518ad): that kept the *earliest* open instance, which is backwards -- the stale one should go and the current one stand -- and it only hid the row in the flat list while leaving it overdue in the timeline and widget, which is where it was actually being seen. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_018AwnALZL6bD4VBtATDVv3B --- migrations/030_abandon_stale_recurrences.sql | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 migrations/030_abandon_stale_recurrences.sql (limited to 'migrations') diff --git a/migrations/030_abandon_stale_recurrences.sql b/migrations/030_abandon_stale_recurrences.sql new file mode 100644 index 0000000..f8ec225 --- /dev/null +++ b/migrations/030_abandon_stale_recurrences.sql @@ -0,0 +1,23 @@ +-- A recurring task that wasn't done before its next iteration arrived is stale, +-- not still-owed: the next one supersedes it. Without a way to record that, every +-- skipped occurrence stayed open forever and piled up as permanent overdue items +-- (found live: "Bills" and "Bones's meds" each sitting in the list twice, an +-- unfinished instance alongside its already-generated successor). +-- +-- Deliberately a separate flag rather than reusing `completed`: these were never +-- done, and marking them completed would falsely credit them and pollute +-- completion history. +ALTER TABLE native_tasks ADD COLUMN abandoned BOOLEAN DEFAULT 0; + +-- Backfill: any uncompleted recurring instance that already has a later sibling +-- in its series was superseded before this flag existed. +UPDATE native_tasks +SET abandoned = 1 +WHERE completed = 0 + AND recurrence_series_id != '' + AND due_date IS NOT NULL + AND EXISTS ( + SELECT 1 FROM native_tasks later + WHERE later.recurrence_series_id = native_tasks.recurrence_series_id + AND later.due_date > native_tasks.due_date + ); -- cgit v1.2.3