diff options
author | Parsa Yousefi <parsa.yousefi@ionos.com> | 2024-09-05 19:18:51 +0200 |
---|---|---|
committer | Gibheer <gibheer+git@zero-knowledge.org> | 2024-09-05 19:18:51 +0200 |
commit | 6f64eeace1b66639b9380b44e88a8d54850a4306 (patch) | |
tree | 2731d0c5ee6412c732dae3e87a618f726744efc1 /cmd/monfront/filter.go | |
parent | 8919bafb3af724de4021854ac374fde7f1911f7f (diff) |
filter muted checks
This adds the possibility to filter for muted checks.
Diffstat (limited to 'cmd/monfront/filter.go')
-rw-r--r-- | cmd/monfront/filter.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/cmd/monfront/filter.go b/cmd/monfront/filter.go index bd82c91..968cb36 100644 --- a/cmd/monfront/filter.go +++ b/cmd/monfront/filter.go @@ -64,6 +64,18 @@ func (f *filter) filterChecks(c *Context) { } f.Add("ac.mapping_id", "=", val[0], "int") f.Vals[arg] = val[0] + case "mute": + if val[0] == "" { + continue + } + isNull := false + if val[0] == "true" { + isNull = true + f.Vals[arg] = "true" + } else if val[0] == "false" { + f.Vals[arg] = "false" + } + f.AddNull("cn.check_id", isNull) } } } @@ -75,6 +87,14 @@ func (f *filter) Add(field, op string, arg interface{}, castTo string) { f.params = append(f.params, arg) } +func (f *filter) AddNull(field string, isNull bool) { + check := "is not null" + if isNull { + check = "is null" + } + f.where = append(f.where, fmt.Sprintf("%s %s", field, check)) +} + // AddSpecial lets you add a special where clause comparison where you can // wrap the argument in whatevery you like. // @@ -82,6 +102,7 @@ func (f *filter) Add(field, op string, arg interface{}, castTo string) { // in the query string. // // Example: +// // AddSpecial("foo", "=", "to_tsvector('english', $%d), search) func (f *filter) AddSpecial(field, op, special string, arg interface{}) { f.idx += 1 |