From 6f64eeace1b66639b9380b44e88a8d54850a4306 Mon Sep 17 00:00:00 2001 From: Parsa Yousefi Date: Thu, 5 Sep 2024 19:18:51 +0200 Subject: filter muted checks This adds the possibility to filter for muted checks. --- cmd/monfront/filter.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'cmd/monfront/filter.go') 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 -- cgit v1.2.3-70-g09d2