mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(alerting): making progress on alerting list, #5784
This commit is contained in:
@@ -161,8 +161,6 @@ func upsertAlerts(existingAlerts []*m.Alert, cmd *m.SaveAlertsCommand, sess *xor
|
||||
alert.Updated = time.Now()
|
||||
alert.Created = time.Now()
|
||||
alert.State = m.AlertStatePending
|
||||
alert.CreatedBy = cmd.UserId
|
||||
alert.UpdatedBy = cmd.UserId
|
||||
|
||||
_, err := sess.Insert(alert)
|
||||
if err != nil {
|
||||
@@ -222,8 +220,10 @@ func SetAlertState(cmd *m.SetAlertStateCommand) error {
|
||||
}
|
||||
|
||||
alert.State = cmd.State
|
||||
sess.Id(alert.Id).Update(&alert)
|
||||
alert.StateChanges += 1
|
||||
alert.NewStateDate = time.Now()
|
||||
|
||||
sess.Id(alert.Id).Update(&alert)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ func addAlertMigrations(mg *Migrator) {
|
||||
Name: "alert",
|
||||
Columns: []*Column{
|
||||
{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
|
||||
{Name: "version", Type: DB_BigInt, Nullable: false},
|
||||
{Name: "dashboard_id", Type: DB_BigInt, Nullable: false},
|
||||
{Name: "panel_id", Type: DB_BigInt, Nullable: false},
|
||||
{Name: "org_id", Type: DB_BigInt, Nullable: false},
|
||||
@@ -23,12 +24,12 @@ func addAlertMigrations(mg *Migrator) {
|
||||
{Name: "paused", Type: DB_Bool, Nullable: false},
|
||||
{Name: "silenced", Type: DB_Bool, Nullable: false},
|
||||
{Name: "execution_error", Type: DB_Text, Nullable: false},
|
||||
{Name: "last_eval_data", Type: DB_Text, Nullable: false},
|
||||
{Name: "last_eval_time", Type: DB_DateTime, Nullable: false},
|
||||
{Name: "eval_data", Type: DB_Text, Nullable: true},
|
||||
{Name: "eval_date", Type: DB_DateTime, Nullable: true},
|
||||
{Name: "new_state_date", Type: DB_DateTime, Nullable: false},
|
||||
{Name: "state_changes", Type: DB_Int, Nullable: false},
|
||||
{Name: "created", Type: DB_DateTime, Nullable: false},
|
||||
{Name: "updated", Type: DB_DateTime, Nullable: false},
|
||||
{Name: "updated_by", Type: DB_BigInt, Nullable: false},
|
||||
{Name: "created_by", Type: DB_BigInt, Nullable: false},
|
||||
},
|
||||
Indices: []*Index{
|
||||
{Cols: []string{"org_id", "id"}, Type: IndexType},
|
||||
|
||||
@@ -32,6 +32,7 @@ func addAnnotationMig(mg *Migrator) {
|
||||
|
||||
// create indices
|
||||
mg.AddMigration("add index annotation org_id & alert_id ", NewAddIndexMigration(table, table.Indices[0]))
|
||||
|
||||
mg.AddMigration("add index annotation org_id & type", NewAddIndexMigration(table, table.Indices[1]))
|
||||
mg.AddMigration("add index annotation timestamp", NewAddIndexMigration(table, table.Indices[2]))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user