Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow tracking "nested intervals" #503

Open
guludo opened this issue Sep 15, 2022 · 5 comments
Open

Allow tracking "nested intervals" #503

guludo opened this issue Sep 15, 2022 · 5 comments
Labels
discussion Discussion on a topic

Comments

@guludo
Copy link

guludo commented Sep 15, 2022

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
Copy link
Contributor

smemsh commented Sep 15, 2022

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...

@lauft lauft added the discussion Discussion on a topic label Sep 27, 2022
@guludo
Copy link
Author

guludo commented Oct 5, 2022

@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
Copy link
Contributor

smemsh commented Oct 5, 2022

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.

@cyberme0w
Copy link
Contributor

Hi!

First things first: Sorry for necro-bumping! I realize this issue is >2 years old, but

  1. it fits my question, and
  2. it's still open, so hopefully it's okay ^^

I am currently looking for a way to do 'hierarchical tagging', and reading @smemsh's comment, it seemed they managed to get something along those lines to work.

Specifically, I am looking for a way to do:

timew start /opensource/timewarrior/debug

and have timewarrior recognize that these are multiple tags on different hierarchical levels.


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.

@smemsh in case you are still around, would you mind sharing how you got this working? I wrote a small wrapper using tr to split the tags and timew tag to add them to the current interval, but I am curious about how you solved this:

#!/bin/sh
#FILE: timew-htags.sh
IN="${@}"
tags=$(echo $IN | tr '/' "\n")

timew start

htag=""
for tag in $tags; do
  htag="$htag/$tag"
  timew tag "$htag"
done

There is still the inconvenience of having all tag levels displayed in the summary. For instance, after running ./timew-htags.sh /opensource/timew/htags, followed by timew su, the following tags are displayed:

Wk  Date       Day Tags                                                       Start End    Time   Total
W45 2024-11-04 Mon /opensource, /opensource/timew, /opensource/timew/htags 15:30:00   - 0:02:06 0:02:06

However, it would make sense to somehow hide the hierarchical tags, as they are already implied by the leaf tag:

Wk  Date       Day Tags                       Start End    Time   Total
W45 2024-11-04 Mon /opensource/timew/htags 15:30:00   - 0:02:06 0:02:06

Furthermore, since each level of the tag is stored, it would allow to filter for /opensource or /opensource/timew, etc.

Anyway, just wanted to throw the question in the room and see if this is something anyone else has worked on already or would be interested in discussing.

Cheers!

@smemsh
Copy link
Contributor

smemsh commented Nov 5, 2024

@cyberme0w my wrapper scripts are all in my taskwtools repo, you might want to look at my task.py's _timewtags() and the on_modify_timew() hook. There's a more thorough explanation of my timewarrior tags concept in the readme.

In the shell I would use timewtags in backticks to expand to all the tags a particular task would get assigned in timewarrior, or taskfql to expand to just the fully qualified hierarchy label of a given task.

There's of course no native notion of hierarchy in timewarrior, but it can be simulated by putting all the tags comprising each level of the hierarchy on any task whose fully qualified tag hierarchy includes those components. With such tags in place, all tasks that share those levels of hierarchy can be selected as a group. I use those for generating reports, project or even category -level accounting, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion on a topic
Projects
None yet
Development

No branches or pull requests

4 participants