fix: alert list panel now works correctly after adding manual annotation on dashboard, fixes #9951

(cherry picked from commit 0d12b37dfd)
This commit is contained in:
Torkel Ödegaard
2017-11-21 11:32:49 +01:00
parent 69a0a8e89c
commit 783355f1d6
5 changed files with 97 additions and 0 deletions
+4
View File
@@ -158,6 +158,10 @@ func (r *SqlAnnotationRepo) Find(query *annotations.ItemQuery) ([]*annotations.I
params = append(params, query.From, query.To)
}
if query.Type == "alert" {
sql.WriteString(` AND annotation.alert_id > 0`)
}
if len(query.Tags) > 0 {
keyValueFilters := []string{}
+14
View File
@@ -42,6 +42,7 @@ func TestAnnotations(t *testing.T) {
UserId: 1,
DashboardId: 1,
Text: "hello",
Type: "alert",
Epoch: 10,
Tags: []string{"outage", "error", "type:outage", "server:server-1"},
})
@@ -89,6 +90,19 @@ func TestAnnotations(t *testing.T) {
So(items, ShouldHaveLength, 0)
})
Convey("Should not find one when type filter does not match", func() {
items, err := repo.Find(&annotations.ItemQuery{
OrgId: 1,
DashboardId: 1,
From: 1,
To: 15,
Type: "alert",
})
So(err, ShouldBeNil)
So(items, ShouldHaveLength, 0)
})
Convey("Should find one when all tag filters does match", func() {
items, err := repo.Find(&annotations.ItemQuery{
OrgId: 1,