feat(alertlistpanel): support state filter

ref #5981
This commit is contained in:
bergquist
2016-09-14 08:36:44 +02:00
parent b49a642ca5
commit d0f9623037
10 changed files with 81 additions and 24 deletions

View File

@@ -87,6 +87,11 @@ func HandleAlertsQuery(query *m.GetAlertsQuery) error {
sql.WriteString(")")
}
if query.Limit != 0 {
sql.WriteString(" LIMIT ?")
params = append(params, query.Limit)
}
alerts := make([]*m.Alert, 0)
if err := x.Sql(sql.String(), params...).Find(&alerts); err != nil {
return err

View File

@@ -3,6 +3,7 @@ package sqlstore
import (
"bytes"
"fmt"
"strings"
"github.com/go-xorm/xorm"
"github.com/grafana/grafana/pkg/services/annotations"
@@ -63,6 +64,13 @@ func (r *SqlAnnotationRepo) Find(query *annotations.ItemQuery) ([]*annotations.I
params = append(params, string(query.Type))
}
if len(query.NewState) > 0 {
sql.WriteString(` AND new_state IN (?` + strings.Repeat(",?", len(query.NewState)-1) + ")")
for _, v := range query.NewState {
params = append(params, v)
}
}
if query.Limit == 0 {
query.Limit = 10
}