summaryrefslogtreecommitdiff
path: root/README.md
blob: 656590c8b371ac01ff14accd62a0cf5b8c590779 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Todoist Repeater

## Background

I use Todoist as my todo app. I add tasks to my Inbox, sorted descending by date added. However, repeating tasks in Todoist don't work with my workflow: they stay in a fixed position in the list, and just refresh the due date.

What I want is a task that appears on a given interval, disappears when it's completed, and, when it's time to do it again, reappears at the top of the list.

Some examples of tasks that I want to recurr in this way:

- each weekday, do a given number of Pomodoros for work
- every day, practice my dance choreography for 15 minutes
- every Monday evening, take out the garbage, recycling, and compost
- every two weeks, wash my bedding
- every six months, wash and condition the leather sofa
- every three months, do a reflection on how I'm feeling about work

## Design

The idea for this program is to:

- have a list of tasks that specifies the task name and the recurrence (interval, start and end date)
- when it's time to add a task to Todoist, use the Todoist API to create the task in my inbox

Here's the API documentation: https://developer.todoist.com/api/v1/

- I can probably get away with not implementing OAuth, and just using an access token
- Creating tasks: https://developer.todoist.com/api/v1/#tag/Tasks/operation/create_task_api_v1_tasks_post (simple because pretty much all I want is the task name)

The hard part is how to specify the input file and recurrence mechanism.

There are some interesting considerations:

- if we somehow weren't running when we should have created a task, should we do so later?
- should we track when we created a task so we don't do it twice somehow?
- how can we handle reloading the input file?
- is DST dangerous?

Seems like https://github.com/robfig/cron is the most popular scheduler, and it doesn't have any dependencies, which I like.

So, here's what I have in mind:

At program start, and every minute thereafter:

- read the input file line by line
- if we've seen a line before, do nothing
- if we have not seen it, add the line to the hash of seen lines; then, add it to the scheduler
- if there were any lines that we did not see during this read of the file, but that we saw previously, remove them from the scheduler

The lines will be formatted like a cron file, but instead of a command, we will simply have the name of the task to be created.

## Future work

It turns out jobs can be added AND removed by an ID that is returned from the Add function. It could be interesting to add/remove based on the last seen map (with the job IDs), instead of completely recreating all the jobs if the input file changes.

We should probably retry failed network requests. It would not be great to have a temporary connectivity issue lead to missing an important task!