feat(alerting): renamed AlertRuleModel to just Alert, think making a distinction between an Alert and an Alert Rule is just confusing and was a mistake on my part

This commit is contained in:
Torkel Ödegaard
2016-06-11 10:26:48 +02:00
parent 2b4a9954b1
commit a362984c57
14 changed files with 38 additions and 45 deletions

View File

@@ -6,7 +6,7 @@ import (
"github.com/grafana/grafana/pkg/components/simplejson"
)
type AlertRuleModel struct {
type Alert struct {
Id int64
OrgId int64
DashboardId int64
@@ -24,17 +24,11 @@ type AlertRuleModel struct {
Expression *simplejson.Json
}
type AlertRules []*AlertRuleModel
func (this AlertRuleModel) TableName() string {
return "alert_rule"
func (alert *Alert) ValidToSave() bool {
return alert.DashboardId != 0
}
func (alertRule *AlertRuleModel) ValidToSave() bool {
return alertRule.DashboardId != 0
}
func (this *AlertRuleModel) ContainsUpdates(other *AlertRuleModel) bool {
func (this *Alert) ContainsUpdates(other *Alert) bool {
result := false
result = result || this.Name != other.Name
result = result || this.Description != other.Description
@@ -51,7 +45,6 @@ func (this *AlertRuleModel) ContainsUpdates(other *AlertRuleModel) bool {
}
//don't compare .State! That would be insane.
return result
}
@@ -70,11 +63,10 @@ type HeartBeat struct {
type HeartBeatCommand struct {
ServerId string
Result AlertingClusterInfo
Result AlertingClusterInfo
}
type AlertRuleChange struct {
type AlertChange struct {
Id int64 `json:"id"`
OrgId int64 `json:"-"`
AlertId int64 `json:"alertId"`
@@ -88,7 +80,7 @@ type SaveAlertsCommand struct {
UserId int64
OrgId int64
Alerts AlertRules
Alerts []*Alert
}
type DeleteAlertCommand struct {
@@ -102,17 +94,17 @@ type GetAlertsQuery struct {
DashboardId int64
PanelId int64
Result []*AlertRuleModel
Result []*Alert
}
type GetAllAlertsQuery struct {
Result []*AlertRuleModel
Result []*Alert
}
type GetAlertByIdQuery struct {
Id int64
Result *AlertRuleModel
Result *Alert
}
type GetAlertChangesQuery struct {
@@ -120,5 +112,5 @@ type GetAlertChangesQuery struct {
Limit int64
SinceId int64
Result []*AlertRuleChange
Result []*AlertChange
}

View File

@@ -31,7 +31,7 @@ type UpdateAlertStateCommand struct {
NewState string `json:"newState" binding:"Required"`
Info string `json:"info"`
Result *AlertRuleModel
Result *Alert
}
// Queries

View File

@@ -13,13 +13,13 @@ func TestAlertingModelTest(t *testing.T) {
json1, _ := simplejson.NewJson([]byte(`{ "field": "value" }`))
json2, _ := simplejson.NewJson([]byte(`{ "field": "value" }`))
rule1 := &AlertRuleModel{
rule1 := &Alert{
Expression: json1,
Name: "Namn",
Description: "Description",
}
rule2 := &AlertRuleModel{
rule2 := &Alert{
Expression: json2,
Name: "Namn",
Description: "Description",