mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
tech(alerting): renames pause all method
This commit is contained in:
@@ -286,8 +286,8 @@ func PauseAlert(c *middleware.Context, dto dtos.PauseAlertCommand) Response {
|
||||
return Json(200, result)
|
||||
}
|
||||
|
||||
//POST /api/alerts/pause
|
||||
func PauseAlerts(c *middleware.Context, dto dtos.PauseAllAlertsCommand) Response {
|
||||
//POST /api/admin/pause-all-alerts
|
||||
func PauseAllAlerts(c *middleware.Context, dto dtos.PauseAllAlertsCommand) Response {
|
||||
updateCmd := models.PauseAllAlertCommand{
|
||||
Paused: dto.Paused,
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ func Register(r *macaron.Macaron) {
|
||||
r.Get("/users/:id/quotas", wrap(GetUserQuotas))
|
||||
r.Put("/users/:id/quotas/:target", bind(m.UpdateUserQuotaCmd{}), wrap(UpdateUserQuota))
|
||||
r.Get("/stats", AdminGetStats)
|
||||
r.Post("/pause-all-alerts", bind(dtos.PauseAllAlertsCommand{}), wrap(PauseAlerts))
|
||||
r.Post("/pause-all-alerts", bind(dtos.PauseAllAlertsCommand{}), wrap(PauseAllAlerts))
|
||||
}, reqGrafanaAdmin)
|
||||
|
||||
// rendering
|
||||
|
||||
@@ -18,10 +18,6 @@ func (c *conditionStub) Eval(context *EvalContext) (*ConditionResult, error) {
|
||||
return &ConditionResult{Firing: c.firing, EvalMatches: c.matches, Operator: c.operator, NoDataFound: c.noData}, nil
|
||||
}
|
||||
|
||||
func (c *conditionStub) GetDatasourceId() (datasourceId *int64, exist bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func TestAlertingExecutor(t *testing.T) {
|
||||
Convey("Test alert execution", t, func() {
|
||||
handler := NewEvalHandler()
|
||||
|
||||
@@ -19,8 +19,8 @@ func init() {
|
||||
bus.AddHandler("sql", GetAllAlertQueryHandler)
|
||||
bus.AddHandler("sql", SetAlertState)
|
||||
bus.AddHandler("sql", GetAlertStatesForDashboard)
|
||||
bus.AddHandler("sql", PauseAlertRule)
|
||||
bus.AddHandler("sql", PauseAllAlertRule)
|
||||
bus.AddHandler("sql", PauseAlert)
|
||||
bus.AddHandler("sql", PauseAllAlerts)
|
||||
}
|
||||
|
||||
func GetAlertById(query *m.GetAlertByIdQuery) error {
|
||||
@@ -250,7 +250,7 @@ func SetAlertState(cmd *m.SetAlertStateCommand) error {
|
||||
})
|
||||
}
|
||||
|
||||
func PauseAlertRule(cmd *m.PauseAlertCommand) error {
|
||||
func PauseAlert(cmd *m.PauseAlertCommand) error {
|
||||
return inTransaction(func(sess *xorm.Session) error {
|
||||
if len(cmd.AlertIds) == 0 {
|
||||
return fmt.Errorf("command contains no alertids")
|
||||
@@ -280,7 +280,7 @@ func PauseAlertRule(cmd *m.PauseAlertCommand) error {
|
||||
})
|
||||
}
|
||||
|
||||
func PauseAllAlertRule(cmd *m.PauseAllAlertCommand) error {
|
||||
func PauseAllAlerts(cmd *m.PauseAllAlertCommand) error {
|
||||
return inTransaction(func(sess *xorm.Session) error {
|
||||
var newState string
|
||||
if cmd.Paused {
|
||||
|
||||
@@ -55,7 +55,7 @@ func TestAlertingDataAccess(t *testing.T) {
|
||||
Paused: true,
|
||||
}
|
||||
|
||||
err = PauseAllAlertRule(cmd)
|
||||
err = PauseAllAlerts(cmd)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
Convey("cannot updated paused alert", func() {
|
||||
|
||||
Reference in New Issue
Block a user