bugfix: query alert event

This commit is contained in:
UlricQin 2021-07-18 16:16:57 +08:00
parent c7b00ee8c6
commit 27daddcb72
1 changed files with 10 additions and 6 deletions

View File

@ -182,9 +182,11 @@ func AlertEventTotal(stime, etime int64, query string, status, priority int) (nu
}
if query != "" {
cond = cond.And(builder.Like{"res_classpaths", "%" + query + "%"})
cond = cond.And(builder.Like{"rule_name", "%" + query + "%"})
cond = cond.And(builder.Like{"tags", "%" + query + "%"})
arr := strings.Fields(query)
for i := 0; i < len(arr); i++ {
qarg := "%" + arr[i] + "%"
cond = cond.And(cond.Or(builder.Like{"res_classpaths", qarg}, builder.Like{"rule_name", qarg}, builder.Like{"tags", qarg}))
}
}
num, err = DB.Where(cond).Count(new(AlertEvent))
@ -211,9 +213,11 @@ func AlertEventGets(stime, etime int64, query string, status, priority int, limi
}
if query != "" {
cond = cond.And(builder.Like{"res_classpaths", "%" + query + "%"})
cond = cond.And(builder.Like{"rule_name", "%" + query + "%"})
cond = cond.And(builder.Like{"tags", "%" + query + "%"})
arr := strings.Fields(query)
for i := 0; i < len(arr); i++ {
qarg := "%" + arr[i] + "%"
cond = cond.And(cond.Or(builder.Like{"res_classpaths", qarg}, builder.Like{"rule_name", qarg}, builder.Like{"tags", qarg}))
}
}
var objs []AlertEvent