-
-
Notifications
You must be signed in to change notification settings - Fork 79
Add support for storing filters in dashboard entries #215
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
Draft
spl3g
wants to merge
12
commits into
traggo:master
Choose a base branch
from
spl3g:filters
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f25e5e3
feat: add server support for storing tag filters
spl3g dcd034b
feat: add TagFilterSelector componenet
spl3g 3d09ce9
feat: add exclude and include tags fields to entry popups
spl3g 09d830f
feat: provide exclude and include tags when querying stats
spl3g ddc80fb
fix: combine excluded and included tags, simplify tag checking
spl3g 2a0474d
fix: remove useState for excludeTags and includeTags
spl3g 97969f4
feat: add includeInputValueOnNoMatch to useSuggest
spl3g da667eb
fix: update handleChange so it opens Downshift automatically
spl3g 25a7a7e
fix: provide handleChange instead of calling it
spl3g a6cf516
fix: check if provided tags list is empty
spl3g af5e6b2
feat: use a transaction when updating dashboard entry
spl3g 7508f5a
fix: replace ordinary db connection with transaction
spl3g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package convert | ||
|
|
||
| import ( | ||
| "github.com/traggo/server/generated/gqlmodel" | ||
| "github.com/traggo/server/model" | ||
| ) | ||
|
|
||
| func tagFiltersToExternal(tags []model.DashboardTagFilter, include bool) []*gqlmodel.TimeSpanTag { | ||
| if len(tags) == 0 { | ||
| return nil | ||
| } | ||
|
|
||
| result := []*gqlmodel.TimeSpanTag{} | ||
| for _, tag := range tags { | ||
| if tag.Include == include { | ||
| result = append(result, &gqlmodel.TimeSpanTag{ | ||
| Key: tag.Key, | ||
| Value: tag.StringValue, | ||
| }) | ||
| } | ||
| } | ||
| return result | ||
| } | ||
|
|
||
| func TagFiltersToInternal(gqls []*gqlmodel.InputTimeSpanTag, include bool) []model.DashboardTagFilter { | ||
| result := make([]model.DashboardTagFilter, 0) | ||
| for _, tag := range gqls { | ||
| result = append(result, tagFilterToInternal(*tag, include)) | ||
| } | ||
| return result | ||
| } | ||
|
|
||
| func tagFilterToInternal(gqls gqlmodel.InputTimeSpanTag, include bool) model.DashboardTagFilter { | ||
| return model.DashboardTagFilter{ | ||
| Key: gqls.Key, | ||
| StringValue: gqls.Value, | ||
| Include: include, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package entry | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/traggo/server/model" | ||
| ) | ||
|
|
||
| func tagsDuplicates(tags []model.DashboardTagFilter) error { | ||
| existingTags := make(map[model.DashboardTagFilter]struct{}) | ||
|
|
||
| for _, tag := range tags { | ||
| if _, ok := existingTags[tag]; ok { | ||
| tagType := "exclude" | ||
| if tag.Include { | ||
| tagType = "include" | ||
| } | ||
|
|
||
| return fmt.Errorf("%s tags: tag '%s' is present multiple times", tagType, tag.Key+":"+tag.StringValue) | ||
| } else { | ||
| copyTag := tag | ||
| copyTag.Include = !copyTag.Include | ||
|
|
||
| if _, ok := existingTags[copyTag]; ok { | ||
| return fmt.Errorf("tag '%s' is present in both exclude tags and include tags", tag.Key+":"+tag.StringValue) | ||
| } | ||
| } | ||
|
|
||
| existingTags[tag] = struct{}{} | ||
| } | ||
|
|
||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to use the existing selector which is used for the timespans (ui/src/tag/TagSelector)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted for it to look more like TagKeySelector, to be more precise, the chips there don't have color and there is an X at the end.
Also I tweaked suggestions a bit (reversed them) so that they will suit the selection more, instead of creation.
Now, that I think about it more, I shouldn't reverse them, but just remove the first entry (user input) and maybe put it at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be okay if i changed useSuggest a little?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, maybe call it can get a name that's describes what it does. E.g. includeInputValueOnNoMatch
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather use the existing picker as it has better UX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'd say changing the style of the existing selector is much easier than reimplementing it. E.g. this makes it look pretty much the same as the other inputs in the form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that using the old selector is easier but i was talking more about the styling and spacing of tag chips.

Also i think it is more tailored towards creating and assigning tags to timespans.


It's a bit strange when an include tags selection field offers you to create a tag:
Or prevents you from adding two identical tag names:
I understand that more props could be added to TagSelector to change this behavior, but this would add more complexity to the component. I think it would be better to keep it within its current scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there are many changes needed in the TagSelector, probably <10 lines of code. I'll insist on this change, but I can do it myself. It'll probably take some time, as I'm busy right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was busy at that time too, but now i can work on this. I can do the changes to the TagsSelect, but first i need to know, what changes do you want.
From my side, i think, this should be changed:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.