Commit 0d12b37d by Torkel Ödegaard

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

parent 14b8bd35
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
## Fixes ## Fixes
* **Gzip**: Fixes bug gravatar images when gzip was enabled [#5952](https://github.com/grafana/grafana/issues/5952) * **Gzip**: Fixes bug gravatar images when gzip was enabled [#5952](https://github.com/grafana/grafana/issues/5952)
* **Alert list**: Now shows alert state changes even after adding manual annotations on dashboard [#9951](https://github.com/grafana/grafana/issues/9951)
# 4.6.2 (2017-11-16) # 4.6.2 (2017-11-16)
......
...@@ -22,6 +22,7 @@ func GetAnnotations(c *middleware.Context) Response { ...@@ -22,6 +22,7 @@ func GetAnnotations(c *middleware.Context) Response {
PanelId: c.QueryInt64("panelId"), PanelId: c.QueryInt64("panelId"),
Limit: c.QueryInt64("limit"), Limit: c.QueryInt64("limit"),
Tags: c.QueryStrings("tags"), Tags: c.QueryStrings("tags"),
Type: c.Query("type"),
} }
repo := annotations.GetRepository() repo := annotations.GetRepository()
......
...@@ -17,6 +17,7 @@ type ItemQuery struct { ...@@ -17,6 +17,7 @@ type ItemQuery struct {
DashboardId int64 `json:"dashboardId"` DashboardId int64 `json:"dashboardId"`
PanelId int64 `json:"panelId"` PanelId int64 `json:"panelId"`
Tags []string `json:"tags"` Tags []string `json:"tags"`
Type string `json:"type"`
Limit int64 `json:"limit"` Limit int64 `json:"limit"`
} }
......
...@@ -158,6 +158,10 @@ func (r *SqlAnnotationRepo) Find(query *annotations.ItemQuery) ([]*annotations.I ...@@ -158,6 +158,10 @@ func (r *SqlAnnotationRepo) Find(query *annotations.ItemQuery) ([]*annotations.I
params = append(params, query.From, query.To) params = append(params, query.From, query.To)
} }
if query.Type == "alert" {
sql.WriteString(` AND annotation.alert_id > 0`)
}
if len(query.Tags) > 0 { if len(query.Tags) > 0 {
keyValueFilters := []string{} keyValueFilters := []string{}
......
...@@ -42,6 +42,7 @@ func TestAnnotations(t *testing.T) { ...@@ -42,6 +42,7 @@ func TestAnnotations(t *testing.T) {
UserId: 1, UserId: 1,
DashboardId: 1, DashboardId: 1,
Text: "hello", Text: "hello",
Type: "alert",
Epoch: 10, Epoch: 10,
Tags: []string{"outage", "error", "type:outage", "server:server-1"}, Tags: []string{"outage", "error", "type:outage", "server:server-1"},
} }
...@@ -91,6 +92,19 @@ func TestAnnotations(t *testing.T) { ...@@ -91,6 +92,19 @@ func TestAnnotations(t *testing.T) {
So(items, ShouldHaveLength, 0) 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() { Convey("Should find one when all tag filters does match", func() {
items, err := repo.Find(&annotations.ItemQuery{ items, err := repo.Find(&annotations.ItemQuery{
OrgId: 1, OrgId: 1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment