Add support for storing filters in dashboard entries#215
Conversation
b2e1e2d to
da667eb
Compare
jmattheis
left a comment
There was a problem hiding this comment.
Currently, this branch doesn't compile:
$ yarn tsc
yarn run v1.22.22
$ /home/jm/src/traggo/server/ui/node_modules/.bin/tsc
src/tag/TagFilterSelector.tsx:99:13 - error TS2322: Type 'void' is not assignable to type '((selectedItem: any, stateAndHelpers: ControllerStateAndHelpers<any>) => void) | undefined'.
99 onChange={handleChange(item, state)}
~~~~~~~~
node_modules/downshift/typings/index.d.ts:40:3
40 onChange?: (
~~~~~~~~
The expected type comes from property 'onChange' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<DownshiftProps<any>, any, any>> & Readonly<...> & Readonly<...>'
src/tag/TagFilterSelector.tsx:99:36 - error TS2304: Cannot find name 'item'.
99 onChange={handleChange(item, state)}
~~~~
src/tag/TagFilterSelector.tsx:99:42 - error TS2304: Cannot find name 'state'.
99 onChange={handleChange(item, state)}
~~~~~
Found 3 errors.
error Command failed with exit code 1.
|
Oh, my bad. I don't know, how i missed that |
|
FYI: There is a test failure and two unresolved conversations. |
|
About the test still failing. The problem is with the sqlite hanging when trying to start a transaction. Removing the SetMaxOpenConns(1) fixes that, but i think that would break something else: if dialect == "sqlite3" {
// We use the database connection inside the handlers from the http
// framework, therefore concurrent access occurs. Sqlite cannot handle
// concurrent writes, so we limit sqlite to one connection.
// see https://github.com/mattn/go-sqlite3/issues/274
// db.DB().SetMaxOpenConns(1)
db.Exec("PRAGMA foreign_keys = ON")
} |
|
Now that the tag selectors PR is merged, I can work on this one. I noticed that when building Stats db query, OR is used both for include and exclude tags. I'm not sure that this is right for include tags. func (r *ResolverForStatistics) Stats(ctx context.Context, ranges []*gqlmodel.Range, tags []string, excludeTags []*gqlmodel.InputTimeSpanTag, requireTags []*gqlmodel.InputTimeSpanTag) ([]*gqlmodel.RangedStatisticsEntries, error) {
...
queryRequire, requireVars := build(requireTags, "1 = 1")
variables = append(variables, requireVars...)
queryExclude, excludeVars := build(excludeTags, "1 != 1")
variables = append(variables, excludeVars...)
...
}
...
func build(tags []*gqlmodel.InputTimeSpanTag, noop string) (string, []interface{}) {
if len(tags) == 0 {
return noop, nil
}
var have []string
var haveParams []interface{}
for _, tag := range tags {
have = append(have, "(tstx.key = ? AND tstx.string_value = ?)")
haveParams = append(haveParams, tag.Key, tag.Value)
}
return strings.Join(have, " OR "), haveParams
} |
|
FYI: This week I'm pretty busy, I'll probably find some time around 22-26 December for testing the changes. |
jmattheis
left a comment
There was a problem hiding this comment.
Awesome, thanks! Will create a release around new year.
|
Released with 0.8.1 |


closes #102
This PR adds support for storing filters and changing them in the dashboard entry form.
It adds 2 new tables for storing filters and a component for choosing them.
I wanted to make it so that the Downshift opens again if the tag is not fully finished, but I could not find a way to do this.
I am open to any suggestions regarding my code, and I haven't written any tests yet.. That's why it's a draft PR.