Torkel Ödegaard 9 лет назад
Родитель
Сommit
0f555d6ab5

+ 3 - 3
pkg/models/alert_state.go

@@ -11,7 +11,7 @@ type AlertState struct {
 	Id              int64            `json:"-"`
 	OrgId           int64            `json:"-"`
 	AlertId         int64            `json:"alertId"`
-	NewState        string           `json:"newState"`
+	State           string           `json:"state"`
 	Created         time.Time        `json:"created"`
 	Info            string           `json:"info"`
 	TriggeredAlerts *simplejson.Json `json:"triggeredAlerts"`
@@ -19,7 +19,7 @@ type AlertState struct {
 
 func (this *UpdateAlertStateCommand) IsValidState() bool {
 	for _, v := range alertstates.ValidStates {
-		if this.NewState == v {
+		if this.State == v {
 			return true
 		}
 	}
@@ -31,7 +31,7 @@ func (this *UpdateAlertStateCommand) IsValidState() bool {
 type UpdateAlertStateCommand struct {
 	AlertId         int64            `json:"alertId" binding:"Required"`
 	OrgId           int64            `json:"orgId" binding:"Required"`
-	NewState        string           `json:"newState" binding:"Required"`
+	State           string           `json:"state" binding:"Required"`
 	Info            string           `json:"info"`
 	TriggeredAlerts *simplejson.Json `json:"triggeredAlerts"`
 

+ 2 - 2
pkg/services/alerting/result_handler.go

@@ -29,7 +29,7 @@ func (handler *ResultHandlerImpl) Handle(result *AlertResult) {
 	if handler.shouldUpdateState(result) {
 		cmd := &m.UpdateAlertStateCommand{
 			AlertId:         result.AlertJob.Rule.Id,
-			NewState:        result.State,
+			State:           result.State,
 			Info:            result.Description,
 			OrgId:           result.AlertJob.Rule.OrgId,
 			TriggeredAlerts: simplejson.NewFromAny(result.TriggeredAlerts),
@@ -62,7 +62,7 @@ func (handler *ResultHandlerImpl) shouldUpdateState(result *AlertResult) bool {
 	lastExecution := query.Result.Created
 	asdf := result.StartTime.Add(time.Minute * -15)
 	olderThen15Min := lastExecution.Before(asdf)
-	changedState := query.Result.NewState != result.State
+	changedState := query.Result.State != result.State
 
 	return changedState || olderThen15Min
 }

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

@@ -47,13 +47,13 @@ func SetNewAlertState(cmd *m.UpdateAlertStateCommand) error {
 			return fmt.Errorf("Could not find alert")
 		}
 
-		alert.State = cmd.NewState
+		alert.State = cmd.State
 		sess.Id(alert.Id).Update(&alert)
 
 		alertState := m.AlertState{
 			AlertId:         cmd.AlertId,
 			OrgId:           cmd.OrgId,
-			NewState:        cmd.NewState,
+			State:           cmd.State,
 			Info:            cmd.Info,
 			Created:         time.Now(),
 			TriggeredAlerts: cmd.TriggeredAlerts,