fix(filters): don't return empty filters in the API response

This commit is contained in:
Łukasz Mierzwa
2018-06-24 17:03:57 +02:00
parent 56a983f31d
commit 5a51898e43
2 changed files with 5 additions and 7 deletions

View File

@@ -781,12 +781,7 @@ var countsMap = models.LabelsCountMap{
},
}
var filtersExpected = []models.Filter{
models.Filter{
Hits: 24,
IsValid: true,
},
}
var filtersExpected = []models.Filter{}
func compareAlertGroups(testCase groupTest, group models.AlertGroup) bool {
if testCase.receiver != group.Receiver {

View File

@@ -96,6 +96,7 @@ func alerts(c *gin.Context) {
// set pointers for data store objects, need a lock until end of view is reached
alerts := []models.AlertGroup{}
colors := models.LabelsColorMap{}
// used for top labels dropdown
counters := models.LabelsCountMap{}
dedupedAlerts := alertmanager.DedupAlerts()
@@ -178,7 +179,9 @@ func alerts(c *gin.Context) {
Hits: filter.GetHits(),
IsValid: filter.GetIsValid(),
}
apiFilters = append(apiFilters, af)
if af.Text != "" {
apiFilters = append(apiFilters, af)
}
}
resp.Filters = apiFilters