-
-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Too many recurrences "hang" task
#3501
Comments
Never creating recurring tasks with past due dates seems fairly safe and better targeted at the problem of returning to an old database. In an ideal future, I would hope all recurring tasks could either have a due date or a (recurrence overhaul) chained or periodic rtype. |
That fix wasn't right! The |
I think I have a better fix: diff --git src/recur.cpp src/recur.cpp
index 524c912d3..bd3f4a08a 100644
--- src/recur.cpp
+++ src/recur.cpp
@@ -74,25 +74,48 @@ void handleRecurrence ()
Context::getContext ().tdb2.modify (t);
Context::getContext ().footnote (onExpiration (t));
continue;
}
// Get the mask from the parent task.
auto mask = t.get ("mask");
+ // Determine the mask index of the first task in the future.
+ unsigned int i = 0;
+ unsigned int first_future = 0;
+ Datetime now;
+ for (auto& d : due)
+ {
+ if (d > now) {
+ first_future = i;
+ break;
+ }
+ ++i;
+ }
+
// Iterate over the due dates, and check each against the mask.
auto changed = false;
- unsigned int i = 0;
+ i = 0;
for (auto& d : due)
{
if (mask.length () <= i)
{
changed = true;
+ // Consider any tasks earlier than the most recent past recurrence
+ // to have been "missed".
+ if (i + 1 < first_future)
+ {
+ mask += 'M';
+ ++i;
+ continue;
+ }
+
Task rec (t); // Clone the parent.
rec.setStatus (Task::pending); // Change the status.
rec.set ("uuid", uuid ()); // New UUID.
rec.set ("parent", t.get ("uuid")); // Remember mom.
rec.setAsNow ("entry"); // New entry date.
rec.set ("due", format (d.toEpoch ()));
if (t.has ("wait")) The idea is similar, but just counts tasks in the past -- except the latest one, as suggested by Max in the meeting today -- as "missed". I'm not sure it's a good idea to use "M" in the mask. Maybe one of the existing symbols ( However, this causes some issues with the tests. In particular, this one seems to be relying on some edge cases or bugs: taskwarrior/test/recurrence.test.py Lines 139 to 164 in d4649dd
This passes without my fix, and I started playing with it without my fix. Just adding an extra Also, running I think I'm too deep into the buggy guts of the recurrence implementation, so I'm going to step back from this bug. It's been a longstanding bug, so I don't feel too bad about throwing it back in the backlog. |
If anyone else wants to try to fix this, please comment and/or assign yourself! |
I just started up
task
in a context where I had a very old task database. It "hung", and some investigation showed it adding tasks for a recurrence. Presumably most of those tasks had due dates in the past, and certainly all of them are not useful.Perhaps we should either have a limit on the number of recurring tasks to create in a given report run, or just never create recurring tasks in the past.
The text was updated successfully, but these errors were encountered: