fix nil pointer
This commit is contained in:
parent
30365a2256
commit
9ccdd6c3e7
|
@ -53,8 +53,16 @@ func alertCurEventsCard(c *gin.Context) {
|
||||||
cardmap := make(map[string]*AlertCard)
|
cardmap := make(map[string]*AlertCard)
|
||||||
for _, event := range list {
|
for _, event := range list {
|
||||||
title := event.GenCardTitle(rules)
|
title := event.GenCardTitle(rules)
|
||||||
|
if _, has := cardmap[title]; has {
|
||||||
cardmap[title].Total++
|
cardmap[title].Total++
|
||||||
cardmap[title].EventIds = append(cardmap[title].EventIds, event.Id)
|
cardmap[title].EventIds = append(cardmap[title].EventIds, event.Id)
|
||||||
|
} else {
|
||||||
|
cardmap[title] = &AlertCard{
|
||||||
|
Total: 1,
|
||||||
|
EventIds: []int64{event.Id},
|
||||||
|
Title: title,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
titles := make([]string, 0, len(cardmap))
|
titles := make([]string, 0, len(cardmap))
|
||||||
|
|
Loading…
Reference in New Issue