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

Time entries: group by #6

Closed
zmoog opened this issue Feb 1, 2023 · 11 comments · Fixed by #8
Closed

Time entries: group by #6

zmoog opened this issue Feb 1, 2023 · 11 comments · Fixed by #8
Assignees
Labels
enhancement New feature or request

Comments

@zmoog
Copy link
Owner

zmoog commented Feb 1, 2023

I want use time entries to get insights about how a spend my time in a given time frame.

The first insight I want to get is the work type (goal, support, hr, sync): show me my work types split.

I usually tag time entries by a type:WORK_TYPE tag.

For example:

$ tgl entries --project-id 178435728 group-by --field tags --start-date 2023-01-30
       Time Entries

  tags           Duration
 ─────────────────────────
  type:meeting   7:38
  type:goal      5:51
  type:support   4:04
  type:sync      3:45
  type:hr        0:54
@zmoog zmoog self-assigned this Feb 1, 2023
@zmoog zmoog added the enhancement New feature or request label Feb 1, 2023
@zmoog
Copy link
Owner Author

zmoog commented Feb 1, 2023

note: I can put together a quick prototype using https://docs.python.org/3/library/itertools.html#itertools.groupby

@zmoog
Copy link
Owner Author

zmoog commented Feb 1, 2023

Evaluate putting some visual hints with https://pypi.org/project/termgraph/

@zmoog
Copy link
Owner Author

zmoog commented Feb 1, 2023

Prototyping a simple 'group by' sub-command for the 'entries' command:

$ tgl entries group-by --field tags --start-date 2023-01-31

        Time Entries

  tags           Duration
 ───────────────────────────
                 8 hours
  type:meeting   3 hours
  type:support   2 hours
  type:sync      an hour
  type:goal      47 minutes
  type:hr        44 minutes

zmoog added a commit that referenced this issue Feb 1, 2023
@zmoog
Copy link
Owner Author

zmoog commented Feb 2, 2023

We need an option to get more resolution on the duration. For example, sometimes I want "an hour", and sometime I want "1:23".

We should add something like --duration-format hh:mm | HUMAN

@zmoog
Copy link
Owner Author

zmoog commented Feb 2, 2023

Here's the test result of switching from

naturaldelta(duration)

to

precisedelta(duration, suppress=["seconds"], format="%0.0f")`:

result:

$ tgl entries group-by --field tags --start-date 2023-02-01                                                                                                                                                           

              Time Entries               
                                         
  tags           Duration                
 ─────────────────────────────────────── 
                 8 hours and 42 minutes  
  type:goal      5 hours and 4 minutes   
  type:sync      1 hour and 27 minutes   
  type:meeting   58 minutes              
                                         

@zmoog
Copy link
Owner Author

zmoog commented Feb 2, 2023

IMO this format is better suited for the granularity of this view. I'm considering to switching to this format as the only option.

@zmoog
Copy link
Owner Author

zmoog commented Feb 3, 2023

After a few tests, the most readable format at glance is the old hh:mm format. Seconds are not relevant at this scale, and the entries rarely last more than a handful of hours.

So I guess I'm sticking with this:

$ tgl entries group-by --field tags

       Time Entries

  tags           Duration
 ─────────────────────────
  type:meeting   3:31
                 2:32
  type:support   1:37
  type:sync      0:47
  type:hr        0:09

@zmoog zmoog changed the title Insights: work types Time entries: group by Feb 3, 2023
zmoog added a commit that referenced this issue Feb 3, 2023
The 'human' format is nice, but it make reading durations at glance
harder.

refs: #6
@zmoog
Copy link
Owner Author

zmoog commented Feb 3, 2023

The next step is adding some project filtering capabilities, so I can only get the time entries for a specific project.

I often want to list or group by entries for work or personal activities.

@zmoog
Copy link
Owner Author

zmoog commented Feb 3, 2023

Here's an example:

$ tgl entries --project-id 178435728 group-by --field tags
       Time Entries

  tags           Duration
 ─────────────────────────
  type:meeting   2:53
  type:support   1:37
  type:sync      0:47
  type:hr        0:09

zmoog added a commit that referenced this issue Feb 3, 2023
The Time Entries API doesn't have filtering options, so I am filtering
the response client side. Not great, we'll see if there are other
options.

refs: #6
@zmoog
Copy link
Owner Author

zmoog commented Feb 4, 2023

I should add the total duration, maybe even a percentage.

@zmoog
Copy link
Owner Author

zmoog commented Feb 4, 2023

The Tables documentation on Rich is amazing https://rich.readthedocs.io/en/latest/tables.html

zmoog added a commit that referenced this issue Feb 4, 2023
The Rich's table has the option of adding a table footer. It adds an
additional row visually distinct from the data rows:

     $ tgl entries --project-id 178435728 group-by --field tags --start-date 2023-01-30

          Time Entries

     tags           Duration
     ─────────────────────────
     type:support   9:40
     type:meeting   7:38
     type:goal      5:58
     type:sync      5:08
     type:hr        0:54
     ─────────────────────────
     Total          29:20

refs: #6
@zmoog zmoog closed this as completed in #8 Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant