Explorar el Código

refactor(alerting): changes interval to string from int

bergquist hace 9 años
padre
commit
96e88ee84d

+ 2 - 2
pkg/models/alerts.go

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

+ 2 - 1
pkg/models/alerts_test.go

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

+ 2 - 2
pkg/services/sqlstore/alerting_test.go

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

+ 1 - 1
pkg/services/sqlstore/migrations/alert_mig.go

@@ -15,7 +15,7 @@ func addAlertMigrations(mg *Migrator) {
 			{Name: "query_ref_id", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "query_ref_id", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "warn_level", 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: "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: "title", Type: DB_NVarchar, Length: 255, Nullable: false},
 			{Name: "description", 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},
 			{Name: "query_range", Type: DB_NVarchar, Length: 255, Nullable: false},