mcndt / obsidian-toggl-integration

A Toggl integration plugin for the popular knowledge base application Obsidian.
GNU General Public License v3.0
267 stars 19 forks source link

Filtering by tag #59

Closed jiri closed 2 years ago

jiri commented 2 years ago

I'd like to be able to filter by tags, not just projects or clients. That would help me view unbilled time as

```toggl
summary past 3 months include projects "Project" exclude tags "Billed"
```

Would it be possible to extend the filtering to include this?

mcndt commented 2 years ago

Hi Jiri, excellent use case. Someone else also asked for better tag support in issue #44, so I think I will flesh something out and lump these two together.

I'm unable to give you a time frame right now for releasing these features, but I will try to push them through relatively soon.

jiri commented 2 years ago

That's awesome to hear, thank you! Let me know if there's anything I can do to help :)

One potential gotcha to watch out for is that unlike projects a task can have multiple tags, so the query grammar should allow both include and exclude 🤔

Also this might be a bit offtopic for this issue but fits in with my billing use case -- I'd love an option to show all entries, unconstrained with a date range (e.g. show me all unbilled time on this project). Is that something that's possible with Toggl's API?

mcndt commented 2 years ago

The Toggl API can be used to query date ranges spanning up to 1 year. However (as you might have noticed), querying all data over 365 days is already quite slow because I need to batch the requests to avoid rate limiting. I think pulling in all time entries since the start of your account will be quite challenging because of that. Not to mention this could easily run into the 10-100 thousands of entries for some users. There might be some query parameters I can tweak so I'll have to dig into the API docs further.

Can you give some example queries of how you want to query tags and the result you expect from them? Especially for queries with double include/exclude expressions.

jiri commented 2 years ago

Ah, I suspected it might be an issue with the API :) Thanks for the writeup!

As for the queries, it's quite simple. Suppose I do some part of my work in Unity and some part of it in Unreal, and I want to see how much time I've done using these that I haven't billed so far, therefore I'd use something like:

```toggl
summary past month include tags #unity, #unreal exclude tags #billed
```

It might be worth considering implementing a full featured algebra for the queries, so you could do expressions like (#unity or #unreal) and not (#unity and #unreal), but that's going to be a bit more work and is probably worth making a separate issue for 😄

mcndt commented 2 years ago

Hmm yeah the tags can get messy as some people might be interested in the intersection of tags while others might want a union....

I had a quick look at how Timery handles tags in their report widgets, and afaict only unions are supported (i.e. #unity OR #unreal, but not #unity AND #unreal).

This implementation would be easily implemented with the existing including/excluding expression, as in your code block.

I think that would suffice for initial support of tags, what do you think?

jiri commented 2 years ago

Definitely, I wouldn't overdo it with the initial support, since there's going to be a lot of other users chiming in with their use cases as well. I mainly care about excluding billed time for my current use case 😁

mcndt commented 2 years ago

Implemented and published in version 0.7.0. Let me know if you have any further feedback!

jiri commented 2 years ago

From some early testing it seems to me that the plugin doesn't support case sensitivity in tags. It works well with lowercase tags but mixed case tags fail to resolve. My guess would be that you convert the tag name to lowercase as a sanity check (for an insane API 😬) somewhere?

mcndt commented 2 years ago

You're right I had to do a lowercase conversion somewhere (Toggl tags have unique casing representation but only one casing can exist). I thought I explicitly fixed that scenario but I'll have another look.

Thanks for reporting!

mcndt commented 2 years ago

Should be fixed in 0.7.1 which I just released.

jiri commented 2 years ago

Seems to work perfectly, thank you!