refactor(alerting): changes interval to string from int

pull/5622/head
bergquist 9 years ago
parent 262821e7e7
commit 96e88ee84d
  1. 4
      pkg/models/alerts.go
  2. 3
      pkg/models/alerts_test.go
  3. 4
      pkg/services/sqlstore/alerting_test.go
  4. 2
      pkg/services/sqlstore/migrations/alert_mig.go

@ -12,7 +12,7 @@ type Alert struct {
QueryRefId string
WarnLevel string
CritLevel string
Interval int64
Interval string
Title string
Description string
QueryRange string
@ -36,7 +36,7 @@ func (cmd *SaveDashboardCommand) GetAlertModels() *[]Alert {
QueryRefId: alerting.Get("query_ref").MustString(),
WarnLevel: alerting.Get("warn_level").MustString(),
CritLevel: alerting.Get("crit_level").MustString(),
Interval: alerting.Get("interval").MustInt64(),
Interval: alerting.Get("interval").MustString(),
Title: alerting.Get("title").MustString(),
Description: alerting.Get("description").MustString(),
QueryRange: alerting.Get("query_range").MustString(),

@ -74,7 +74,7 @@ func TestAlertModel(t *testing.T) {
"description": "Restart the webservers",
"query_range": "5m",
"aggregator": "avg",
"interval": 10
"interval": "10"
},
"targets": [
{
@ -282,6 +282,7 @@ func TestAlertModel(t *testing.T) {
So(v.QueryRange, ShouldNotBeEmpty)
So(v.Title, ShouldNotBeEmpty)
So(v.Description, ShouldNotBeEmpty)
So(v.Interval, ShouldEqual, "10")
fmt.Println(v.Query)
}

@ -20,7 +20,7 @@ func TestAlertingDataAccess(t *testing.T) {
QueryRefId: "A",
WarnLevel: "> 30",
CritLevel: "> 50",
Interval: 10,
Interval: "10",
Title: "Alerting title",
Description: "Alerting description",
QueryRange: "5m",
@ -45,7 +45,7 @@ func TestAlertingDataAccess(t *testing.T) {
alert, err2 := GetAlertsByDashboard(1, 1)
So(err2, ShouldBeNil)
So(alert.Interval, ShouldEqual, 10)
So(alert.Interval, ShouldEqual, "10")
So(alert.WarnLevel, ShouldEqual, "> 30")
So(alert.CritLevel, ShouldEqual, "> 50")
So(alert.Query, ShouldEqual, "Query")

@ -15,7 +15,7 @@ func addAlertMigrations(mg *Migrator) {
{Name: "query_ref_id", Type: DB_NVarchar, Length: 255, Nullable: false},
{Name: "warn_level", Type: DB_NVarchar, Length: 255, Nullable: false},
{Name: "crit_level", Type: DB_NVarchar, Length: 255, Nullable: false},
{Name: "interval", Type: DB_BigInt, Nullable: false},
{Name: "interval", Type: DB_NVarchar, Length: 255, Nullable: false},
{Name: "title", Type: DB_NVarchar, Length: 255, Nullable: false},
{Name: "description", Type: DB_NVarchar, Length: 255, Nullable: false},
{Name: "query_range", Type: DB_NVarchar, Length: 255, Nullable: false},

Loading…
Cancel
Save