code refactor

This commit is contained in:
UlricQin 2021-07-18 16:39:10 +08:00
parent 0a29fb89c4
commit 562f3ea937
1 changed files with 10 additions and 2 deletions

View File

@ -185,7 +185,11 @@ func AlertEventTotal(stime, etime int64, query string, status, priority int) (nu
arr := strings.Fields(query) arr := strings.Fields(query)
for i := 0; i < len(arr); i++ { for i := 0; i < len(arr); i++ {
qarg := "%" + arr[i] + "%" qarg := "%" + arr[i] + "%"
cond = cond.Or(builder.Like{"res_classpaths", qarg}, builder.Like{"rule_name", qarg}, builder.Like{"tags", qarg}) innerCond := builder.NewCond()
innerCond = innerCond.Or(builder.Like{"res_classpaths", qarg})
innerCond = innerCond.Or(builder.Like{"rule_name", qarg})
innerCond = innerCond.Or(builder.Like{"tags", qarg})
cond = cond.And(innerCond)
} }
} }
@ -216,7 +220,11 @@ func AlertEventGets(stime, etime int64, query string, status, priority int, limi
arr := strings.Fields(query) arr := strings.Fields(query)
for i := 0; i < len(arr); i++ { for i := 0; i < len(arr); i++ {
qarg := "%" + arr[i] + "%" qarg := "%" + arr[i] + "%"
cond = cond.Or(builder.Like{"res_classpaths", qarg}, builder.Like{"rule_name", qarg}, builder.Like{"tags", qarg}) innerCond := builder.NewCond()
innerCond = innerCond.Or(builder.Like{"res_classpaths", qarg})
innerCond = innerCond.Or(builder.Like{"rule_name", qarg})
innerCond = innerCond.Or(builder.Like{"tags", qarg})
cond = cond.And(innerCond)
} }
} }