GothenburgBitFactory / timewarrior

Timewarrior - Commandline Time Tracking and Reporting
https://timewarrior.net
MIT License
1.2k stars 91 forks source link

Allow tracking "nested intervals" #503

Open guludo opened 1 year ago

guludo commented 1 year ago

Consider the following use case:

A user is working on multiple projects and is using taskwarrior to track time spent on each project. Let's say that project A uses a ticketing system and the user would like to be able to use taskwarrior to track time spent on each ticket. Since the user is already tracking time on project A, taskwarrior can't be used to track the ticket time, because timew start will cause the tracking of project A to stop.

To solve that, we could allow "nested intervals" to be recorded. This would turn timewarrior into a "hierarchical" time-tracking system.

smemsh commented 1 year ago

Intervals can each have arbitrary tags, so you can just add whatever tags you want to be associated with those intervals, to implement a hierarchical view of those tags. I use /tags/like/this but then also would put the tags /tags/like/ and /tags/ on that same interval. This way I can query all intervals collectively at different levels of hierarchy, or the tasks themselves. "Leaf" tags are those without a trailing slash, and represent a single thing worked on. YMMV...

guludo commented 1 year ago

@smemsh That could work, but, if I understand it correctly, that would require me listing every level of the hierarchy in the command line, right? Example:

timew start /a # Start working on a: non-specific tasks
timew start /a /a/b # Start to work specifically on b
timew start /a /a/c # Stop b and start c
timew stop

If we added the ability to use nested intervals, we could do something like below:

timew start /a
timew push /a/b  # Start nested interval
timew pop # Stop nested interval
timew push /a/c
timew pop
timew stop

As with the current version, the structure of the names of the tags would be transparent to timewarrior, the user could use whatever tag she wanted. What would tell timewarrior that we are nesting intervals would be the push subcommand.

smemsh commented 1 year ago

That could work, but, if I understand it correctly, that would require me listing every level of the hierarchy in the command line, right? Example: timew start /a # Start working on a: non-specific tasks timew start /a /a/b # Start to work specifically on b timew start /a /a/c # Stop b and start c timew stop

Personally I only work on leaf tasks, and don't use containers. However the containers are emergent based on the tags, which for me are installed automatically via wrappers and triggers, so I don't have to write them all. These extra tags are useful for accounting or selection after the fact, but not for logging. I feel there is only one task worked at a time so nesting them per se doesn't make sense for my work flow. Therefore I only use leaves. If I need to tally time spent on related tasks that share some hierarchy, I can do that (such as, for tasks a/1, a/2, and a/3, they would all have tag a/ so I can sum that one to get their combined total or otherwise select all a/ prefixed tags).

But, I do get your suggestion and can see that some might find it useful.