code refactor

This commit is contained in:
Ulric Qin 2022-03-22 14:38:56 +08:00
parent 106345ff49
commit 2cd9f50357
2 changed files with 4 additions and 6 deletions

View File

@ -68,6 +68,10 @@ func (e *AlertCurEvent) GenCardTitle(rules []*AggrRule) string {
if rule.Type == "tagkey" {
arr[i] = e.GetTagValue(rule.Value)
}
if len(arr[i]) == 0 {
arr[i] = "Null"
}
}
return strings.Join(arr, "::")
}

View File

@ -1,7 +1,6 @@
package router
import (
"fmt"
"sort"
"strings"
@ -47,9 +46,6 @@ func alertCurEventsCard(c *gin.Context) {
list, err := models.AlertCurEventGets(busiGroupId, stime, etime, severity, clusters, query, 10000, 0)
ginx.Dangerous(err)
fmt.Println(">>>> len:", len(list))
fmt.Println(">>>> list", list)
cardCount := make(map[string]int)
for _, event := range list {
title := event.GenCardTitle(rules)
@ -63,8 +59,6 @@ func alertCurEventsCard(c *gin.Context) {
sort.Strings(titles)
fmt.Println(">>>> titles:", titles)
cards := make([]AlertCard, len(titles))
for i := 0; i < len(titles); i++ {
cards[i] = AlertCard{