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

Add command to group entries by field #8

Merged
merged 7 commits into from
Feb 4, 2023
Merged

Add command to group entries by field #8

merged 7 commits into from
Feb 4, 2023

Conversation

zmoog
Copy link
Owner

@zmoog zmoog commented Feb 3, 2023

Motivation

We want to add a new CLI command tgl entries group-by to group time entries by one of the entry attributes.

Here's an example if a group by tags:

$ 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

Change description

  • We leverage the Rich table component for displaying a footer.
  • Sum and formatting happen locally in the result module.
  • The Time Entries API does not offer filtering options, so we're doing it client side.

Additional Notes

Closes: #6

Reviewer checklist

  • PR address a single concern.
  • PR title and description are appropriately filled.
  • Changes will be merged in main.
  • Changes are covered by tests.
  • Logging is meaningful in case of troubleshooting.
  • Docs are updated (at least the README.md, if needed).
  • History is clean, commit messages are meaningful (see CONTRIBUTING.md) and are well-formatted.

The 'human' format is nice, but it make reading durations at glance
harder.

refs: #6
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 zmoog self-assigned this Feb 3, 2023
@zmoog zmoog added the enhancement New feature or request label Feb 3, 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 marked this pull request as ready for review February 4, 2023 06:38
Running timers have a negative duration that would impact totals.
We are now showing:

- tgl entries list
- tgl entries list --project-id 123
- tgl entries group-by --field tags
I should lower the maintenance cost of these tests!
@zmoog zmoog changed the title Time Entries: group by entry field Add command to group entries by field Feb 4, 2023
@zmoog zmoog merged commit c432440 into main Feb 4, 2023
@zmoog zmoog deleted the zmoog/insights branch February 4, 2023 07:10
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 this pull request may close these issues.

Time entries: group by
1 participant