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

Support exclude filtering by tag #187

Closed
rkj opened this issue Apr 18, 2022 · 3 comments
Closed

Support exclude filtering by tag #187

rkj opened this issue Apr 18, 2022 · 3 comments

Comments

@rkj
Copy link

rkj commented Apr 18, 2022

Would be nice if report could total all the activity excluding some with specific tag(s), e.g.:

9:00 - 9:30 #project1 do some work
9:30 - 10:00 #break
10:00 - 10:30 #project2 some other work

and then doing something like

$ klog report --tags=-break
@rkj
Copy link
Author

rkj commented Apr 19, 2022

Oh my, this is fun one to do using json. Not super readable, but doable:

  klog json --today | jq '.records[-1].total_mins as $total |
    (.records[-1].entries | map(select(.tags[] | contains("home") or contains("break"))) |
    [.[].total_mins] | add) as $personal |
    ($total - $personal) as $time |
    "\($time / 60 | floor)h\($time % 60)m"
  '

It would be nice if was natively supported in all the reporting commands.

@jotaen
Copy link
Owner

jotaen commented Apr 19, 2022

Thanks for your thoughts, and cool that you were able to work around via klog json for now.

I think this is a broader topic, so I’ve created #190 for a place to discuss ideas and approaches.

@jotaen jotaen closed this as completed Apr 19, 2022
@rkj
Copy link
Author

rkj commented Apr 19, 2022

Thanks @jotaen!

Here is more readable version of my script:

# Prints how much work time happened today.
work() {
  klog json "$@" |
    jq '
      def fmt_time($mins): "\($mins / 60 | floor)h\($mins % 60)m";
      def with_tags: map(select(.tags[] | contains("home") or contains("break")));
      .records[] |
      {
        date: .date,
        total: .total_mins,
        personal: .entries | with_tags | [.[].total_mins] | add
      } |
        "\(.date): \(fmt_time(.total - .personal))"
  '
}

it's not too bad, just not well integrated.

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

No branches or pull requests

2 participants