From 96e88ee84dbcb81056b6c49dc0ee49c3cc7414d5 Mon Sep 17 00:00:00 2001 From: bergquist Date: Wed, 20 Apr 2016 16:57:03 +0200 Subject: [PATCH] refactor(alerting): changes interval to string from int --- pkg/models/alerts.go | 4 ++-- pkg/models/alerts_test.go | 3 ++- pkg/services/sqlstore/alerting_test.go | 4 ++-- pkg/services/sqlstore/migrations/alert_mig.go | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/models/alerts.go b/pkg/models/alerts.go index ef4dd190235..310f5b87aa1 100644 --- a/pkg/models/alerts.go +++ b/pkg/models/alerts.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(), diff --git a/pkg/models/alerts_test.go b/pkg/models/alerts_test.go index 5a74670e838..3f0870d3e63 100644 --- a/pkg/models/alerts_test.go +++ b/pkg/models/alerts_test.go @@ -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) } diff --git a/pkg/services/sqlstore/alerting_test.go b/pkg/services/sqlstore/alerting_test.go index 296fcb810c0..a23ea106dbb 100644 --- a/pkg/services/sqlstore/alerting_test.go +++ b/pkg/services/sqlstore/alerting_test.go @@ -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") diff --git a/pkg/services/sqlstore/migrations/alert_mig.go b/pkg/services/sqlstore/migrations/alert_mig.go index 8aab5fb3b07..138bb1f9f46 100644 --- a/pkg/services/sqlstore/migrations/alert_mig.go +++ b/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: "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},