From 5a51898e439b30e5410f7ecc6abf128b7405d0c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Sun, 24 Jun 2018 17:03:57 +0200 Subject: [PATCH] fix(filters): don't return empty filters in the API response --- api_test.go | 7 +------ views.go | 5 ++++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/api_test.go b/api_test.go index e08a7bf2b..fb635104b 100644 --- a/api_test.go +++ b/api_test.go @@ -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 { diff --git a/views.go b/views.go index 76f4d8cfc..7446bda5d 100644 --- a/views.go +++ b/views.go @@ -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