lyz-code / pydo

Command line task manager built with Python and SQLite.
https://lyz-code.github.io/pydo
GNU General Public License v3.0
20 stars 4 forks source link

Add time tracking support #35

Open lyz-code opened 4 years ago

lyz-code commented 4 years ago

Implement start and stop commands to be able to measure how much time is spent in a task.

Integrate it into the reports.

xeruf commented 4 years ago

Why not integrate with timewarrior instead? Isn't this the sort of scope-creep/NIH-syndrome you wanted to avoid?

lyz-code commented 4 years ago

Timewarrior as far as I remember (from the time I've implemented timing support for taskwarrior) relies on adding annotations to the tasks through hooks. Which I feel is a not very clean workaround if you are using your annotations for other purposes. Even more when that information is already in taskwarrior's undo.data.

Back then I decided to propose a solution that used that data instead. I made several PRs to tasklib to solve the problem, which are still open and unanswered since January of 2018 :(.

I've been using my solution since then, but as the undo.data starts to grow (~1000 open or completed tasks), the performance drops to below ground. For example, I periodically pruned the undo.data to only retain the last year's task information. I also implemented a cache system so consecutive queries to the parsed undo.data object were faster (by addind the problem of synchronization). With that scenario, a Kanban report of the time spent in the last 7 days could take 5 minutes. So parsing undo.data and doing operations on the parsed result is really expensive.

My solution can be further improved by doing ETLs on the tasks and saving the data on udas, but again we'd enter into synchronization issues and it will be another workaround over a workaround.

In the end I took the decision that it was best to build a new tool rather than trying to keep fixing one that I wasn't happy with.

xeruf commented 4 years ago

Timewarrior as far as I remember (from the time I've implemented timing support for taskwarrior) relies on adding annotations to the tasks through hooks.

Nope, timewarrior has its own database and can operate completely independently from taskwarrior. The hooks are only one-way - propagating taskwarrior updates to timewarrior.

If you built some hook system here that would send start/stop timestamp and task data over, timewarrior could easily be used.

xeruf commented 4 years ago

oh, and timewarrior development isn't as stale as in taskwarrior. In fact, I am on the edge of getting a nice improvement merged.

lyz-code commented 4 years ago

Looks good! When the time comes, we'll definitely evaluate the integration of timewarrior instead of rewriting everything from scratch.

Each approach has it's advantages and inconveniences.

Thanks for the tip