From c8ffa615f0884e5378a00eb9423e193a8ffa407f Mon Sep 17 00:00:00 2001 From: Keith Smith Date: Tue, 3 Feb 2026 16:52:06 -0700 Subject: [PATCH] Fix recurring task duplication bug Prevent process_recurring_tasks from creating duplicate tasks for dates that already have completed instances. Previously only checked for pending tasks, causing old completed recurring tasks to reappear as pending when subsequent instances went overdue. Co-Authored-By: Claude Sonnet 4.5 --- notifications/tasks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notifications/tasks.py b/notifications/tasks.py index 377bc73..c9a0232 100644 --- a/notifications/tasks.py +++ b/notifications/tasks.py @@ -161,12 +161,12 @@ def process_recurring_tasks(): next_due_date = task.calculate_next_due_date() if next_due_date: # Check if we already created this recurrence + # Check for any task (pending OR completed) to avoid duplicates existing = Task.objects.filter( user=task.user, title=task.title, due_date=next_due_date, - recurrence=task.recurrence, - status='pending' + recurrence=task.recurrence ).exists() if not existing: