VladimirMarkelov / ttdl

TTDL - Terminal Todo List Manager
MIT License
210 stars 17 forks source link

Completing task with threshold and rec should create new task #52

Closed SevereOverfl0w closed 2 years ago

SevereOverfl0w commented 3 years ago

I noticed that a task containing t: and rec: will not recur like a task containing due: will.

/tmp
❯ ttdl --local add 'Task t:today rec:1w'
Added todo:
# D P Created    Finished   Due        Subject
-----------------------------------------------
1 R   2021-10-03                       Task t:2021-10-03 rec:1w

/tmp
❯ ttdl --local done 1                   
Changed todos:
# D P Created    Finished   Due        Subject
-----------------------------------------------
1 x   2021-10-03 2021-10-03            Task t:2021-10-03 rec:1w
-----------------------------------------------
1 todos

/tmp
❯ ttdl --local list  
# D P Created    Finished   Due        Subject
-----------------------------------------------
-----------------------------------------------
0 todos (of 1 total)

Note, some tasks might have both t: and due: with different dates set (e.g. report is due on a date, but the data for it isn't ready until 3 days before the due date).

VladimirMarkelov commented 3 years ago

I never used threshold in my todo lists, and did not know about that bug. Thanks for reporting!

VladimirMarkelov commented 2 years ago

Note, some tasks might have both t: and due: with different dates set

In the beginning, I tried a few way to deal with t and due. One way was: on done increase both t and due by rec. I think it is expected behavior. And as I cannot use the easy solution I was thinking of, it take a little time more.

SevereOverfl0w commented 2 years ago

I believe this is the behaviour other tools use, yes!

VladimirMarkelov commented 2 years ago

A question: what is the best way to deal with threshold when creating new task in case of both due and threshold dates exist? As far as I understand, the threshold must be less than due date. So, I cannot apply the same algorithm to both threshold and due dates. Because it may make them the same. At this moment I chose the following rules:

  1. Calculate difference between current due and threshold values
  2. Calculate next due date
  3. Subtract difference from new date

Does it look good for you?

P.S. For case: recurrence and threshold are set, but due date is missing, the threshold is increased using existing rules for due dates. I do not think there is another way in this case.

SevereOverfl0w commented 2 years ago

As far as I understand, the threshold must be less than due date.

Not true. I often set them to be the same! I can't action some tasks until the day it is due (e.g. picking up dry cleaning). One big reason I use due dates is because SimpleTask puts them onto my calendar.

This algorithm you describe is different from how SimpleTask and topydo behave which are my frame of reference. Here's the code in SimpleTask for marking a task as complete which shows the algorithm in use: https://github.com/mpcjanssen/simpletask-android/blob/3394b4e1bd901cce87e059eac4b2af71c93e2c50/app/src/main/java/nl/mpcjanssen/simpletask/task/Task.kt#L176-L201

I think you can treat them in exactly the same way, and it's OK if they are set to the same date when using rec:2d. Mostly I use the format with + rec:+2d with tasks with a due date where I care about preserving the gap between the due & threshold date.

VladimirMarkelov commented 2 years ago

I thought that keeping gap the same was the most important. Doing the way you describe is easier to implement, but in case of non-strict recurrence, it makes both threshold and due the same after the very first done which makes threshold kind of useless for non-strict recurrent task. I did not think it was intended, so I implemented "the constant gap". On the other hand, I think, that having both recurrence and threshold is not common, so it may be good enough solution.

Anyway, even in strict mode, it is possible to get threshold == due because +1m always generates a date within the next month. The corner case is like t:2020-01-29 due:2020-01-31. As February has only 29 days, after done it generates t:2020-02-29 due:2020-02-29. Zero gap instead of two days.

If all corner cases above are not a problem, I can implement it this way: just increase both threshold and due date without trying to keep a gap.

VladimirMarkelov commented 2 years ago

In 3.1.0 threshold date and due dates are treated the same way: both are increased by todo's recurrence.

SevereOverfl0w commented 2 years ago

That's great, thanks! I'm updating now and will give it a spin.