# RULES

- For every implementation update the readme
- For every implementation update or add tests
- Run tests
- AVoid using emojis


## Reminder service

### Multiple databases

I want the reminder service to operate on
multiple databases, lets say I have on my config

```
[reminder]
databases = ["tasks.db", "path/to/other.db", ...]

```

And also if I pass to the cli it overrides what is on the config file.

```
dolist service --databases tasks.db:path/to/other.db
```

This will make the service to watch for reminder on all those databases, for every cycle of execution the service will also loop the databases and process reminders on each one, so I don't need to spawn multiple services for each database.

### notification action

By default, the service spawns a `notify-send` which on most systems will show the notification and a `dismiss` button, however notification systems also allow to add an `activate` button.

Can the default behavior be: If user clicks
`delay` it will then add a delay to the task.
If user clicks `activate` it will then open the user deafult shell with `dolist ID edit`

Python example:

```
import notify2

def on_action(n, action):
    print("Action triggered:", action)

notify2.init("Example")
n = notify2.Notification("Reminder", "Take a break")
n.add_action("snooze", "Snooze", on_action)
n.add_action("dismiss", "Dismiss", on_action)
n.show()

# The handler runs when user clicks a button.

```
## Reports

Metrics I am looking for:

- Total number of tasks created by period (day, week, month, year)
- Tasks per status per period (how much new, in-progress, done, percentage)
- tasks per tag per period

Based on the data from the tasks and history,
I want to be able to run:

### TUI report

I open the tui normally `dolist` then I
can filter tasks, or perform a search.

based on what is visible I press `p` (Plot)

It opens a screen showing the metrics using charts, I want pie charts and bar charts when it makes more sense.

User can change the period and the metrics will imeditelly reflect/replot.

### CLI report

`dolist ls --report`

Will simply output a json with data for each metric

If there are filters applied to `ls` those will be taken in consideration.


## Priorities and Sizes

Add 2 new fields to the task and taskhistory models
- `priority: int`
- `size: str`

Priority is set to a number, default `0`
user can pass `--priority` to the cli
user can setr priority on the TUI edit modal
user can use `> priority 1` on the markdown when importing
user can click priority column to sort
user can use priority=n on search


Size can have 4 possible values U, S, M, L
user can set `--size S` or `--size Small` (M, Medium, L, Large).
The input is case insensitive, in any case only the first capital letter is stored, so the db value is either S,M,L.

User can click the column to sort by this field
user can use `size=S` `size=small` to search (case insensitive etc)

User can set `> size S` when importing from markdown.

When opening the TUI, tasks are sorted by default,
by `priority,created` then user can use one command or click on colums to re-sort.

When not set, the default size is U (Undefined)

### DB migration:

For the case someone runs the program on an old database with existing tasks, the program must on startup identify the table mismatch and perform the proper migration (you can use a migration table to keep track if you want) but the system must keep working and all existing tasks updated with the new columns and its default values.


## Task dependency

We gonna user the existing notes system to track
task dependency, so take this example

```
$ dolist add "Turn on the oven"
Task id 2 created

$ dolist add "bake the cake" --note "depends #2"
```

Right now this will simply add `depends #2` as a note

markers are:

- depends #n
- under #n

then what I want form it.

### TUI and CLI

Tasks that depends on another tasks, will show
status `blocked`, the task name will show `2! name`
which will indicate that the task is blocked by `2`
its title color will be red-ish.

User cannot set a task to this status manually
User cannot change the status of this task
Status of this task is immutable
User can edit all other fields, including notes
but not the status

---

Tasks that are under another task will have a
simple indicator on its name column `n> name`
for example: `3> this is a task` where `3` is the parent. its title color will be yellowish

On any of those cases, on tui, user can type `p` to go to parent, so if I am on `3> this is a task` and I press `p` my cursor goes to the task `3` the same for `2! this is blocked`

---

Then, when I am with a parent taske e.g: `Turn on the oven (1)` under my cursor inside the parhentesis it will show how many children it have, if none, then parenthesis do not show.

If I hit `c` then a search is applied `under=2` and I can see the child tasks on the results.

---

For the cli the same search filters must be available
and also the visual indicators.

```
dolist ls --under 3
```

regardless if the term used is `under` or `depends` we will consider the tasks to be `under`.

The `depends` takes precedence over the under for visual style.

# Recurring taks


The reminder system, must be more intelligent

currently it supports `2 weeks`

I want it to support `2 weeks repeat`


e.g:

```
dolist add "Drink Water" --remind 2 hours repeat
```

Then I will get a reminder triggered in 2 hours,
then instead of cleaning up, the service will set
it again for `2 hours repeat`.
