feat(alerting): moved alerting models back to alerting package, models is more for storage dtos

This commit is contained in:
Torkel Ödegaard
2016-06-06 10:31:21 +02:00
parent 70cb8400c3
commit a191b9b1cf
19 changed files with 578 additions and 313 deletions
-21
View File
@@ -112,24 +112,3 @@ type GetAlertChangesQuery struct {
Result []AlertRuleChange
}
type AlertJob struct {
Offset int64
Delay bool
Running bool
RetryCount int
Rule AlertRule
}
type AlertResult struct {
Id int64
State string
ActualValue float64
Duration float64
Description string
AlertJob *AlertJob
}
func (ar *AlertResult) IsResultIncomplete() bool {
return ar.State == AlertStatePending
}
+3 -18
View File
@@ -2,6 +2,8 @@ package models
import (
"time"
"github.com/grafana/grafana/pkg/services/alerting/alertstates"
)
type AlertState struct {
@@ -13,25 +15,8 @@ type AlertState struct {
Info string `json:"info"`
}
var (
VALID_STATES = []string{
AlertStateOk,
AlertStateWarn,
AlertStateCritical,
AlertStateAcknowledged,
AlertStateMaintenance,
}
AlertStateOk = "OK"
AlertStateWarn = "WARN"
AlertStateCritical = "CRITICAL"
AlertStateAcknowledged = "ACKNOWLEDGED"
AlertStateMaintenance = "MAINTENANCE"
AlertStatePending = "PENDING"
)
func (this *UpdateAlertStateCommand) IsValidState() bool {
for _, v := range VALID_STATES {
for _, v := range alertstates.ValidStates {
if this.NewState == v {
return true
}
-15
View File
@@ -1,15 +0,0 @@
package models
type TimeSeries struct {
Name string `json:"name"`
Points [][2]float64 `json:"points"`
}
type TimeSeriesSlice []*TimeSeries
func NewTimeSeries(name string, points [][2]float64) *TimeSeries {
return &TimeSeries{
Name: name,
Points: points,
}
}