traggo / server

self-hosted tag-based time tracking
https://traggo.net
GNU General Public License v3.0
1.21k stars 58 forks source link

By-Value Filtering of Tags in Dashboard Entries #102

Open Philfreeze opened 3 years ago

Philfreeze commented 3 years ago

Is your feature request related to a problem? Please describe. I currently have tags that are more or less hierarchical in nature. an example would be exactly the one given on the website where you have projects (proj) and types of work (type). I would now like to display a Dashboard (pie chart to be precise) showing the the distribution of type of work for one project. If this is possible, I have not found out how I can do this. (And from looking at the code for 2-3min I don't think it is possible as Dashboard Entries only save the tags keys but no values)

Describe the solution you'd like I would like to be able to enter something like "proj:traggo type" in the Tags field of a Database Entry to show me a graph of tag "type" filtered for entries that also have the key-value pair "proj:traggo".

Describe alternatives you've considered An additional field in the Database Entry that defines filters would also be a viable option, otherwise I do not see how I could do this without basically duplicating my type tags for all projects (so I would have "type-traggo:" and "type-gotify:" instead of just "type:". This is a viable solution if you do not have many projects but the amount of work required to do this increases linearly with the amount of projects while also getting harder and harder to manage.

Additional context As mentioned above, this change is mostly useful for people with a lot of projects. For example students (like me) that have a lot of courses and personal projects and would like to create graphs for each course in order to check the time-breakdown for each. I am pretty sure this change would also allow for some other things that I cannot think of.

A more elaborate system would be based on my suggestion but extended by a 'not equal' option. So you could write something like "!proj:traggo type" to display a graph of types where the entries do not contain the "proj:traggo" key-value pair. This addition would allow for things like easy archiving, you could add "archive:true" to things that should be archived and then add "!archive:true" to all graphs so they do NOT display these entries anymore.

jmattheis commented 3 years ago

Hey @Philfreeze,

thank you for your well-written issue (:. Actually, the backend already supports both your use-cases. On each dashboard entry, there is an included / excluded tags list that should limit the timespans that are used for aggregation.

https://github.com/traggo/server/blob/fa3bf2ca0c713485c4d0f4f617b151a5cbfd3365/schema.graphql#L219-L226

or this backend test

The only part that is missing is the UI part, in there a tag selector should be added to the dashboard entry form.

Stivius commented 2 years ago

That would be a very useful feature for me as well. As I see, UI part still doesn't support this feature?

jmattheis commented 2 years ago

No, the UI still doesn't support this feature.

sanderr commented 1 year ago

I would love to see this feature, so I thought I'd make an attempt to implement it. From the comments above I understood that it was only the UI that doesn't support it, but is it possible the server's DashboardEntry doesn't support it either? My changes seem to perform the appropriate graphql queries (though I should disclaim I'm very inexperienced in TypeScript) but they do not seem to be returned from the server.

I had a look at DashboardEntry and AddDashboardEntry and as far as I can tell they ignore the include and exclude fields.

Since I've never written a line of Go in my life, I'm not sure if I'm going to continue with this but I thought you might be interested to know this seems to be at least slightly broader than just a UI issue. In case you're interested, my changes can be found here. I think the UI part is probably pretty ok (though it wouldn't surprise me if I missed some things) but the server part I just hacked some things in a first rough attempt and quit midway through, so that part's in a very rough and incomplete state.

jmattheis commented 1 year ago

Yeah, looks like only the statistics part is implemented (which should be the difficult part). What's missing from the backend is storing the included and excluded tags in the database when creating and changing the dashboard entries.