mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(alerting): add support for deleting alert rules
This commit is contained in:
@@ -13,6 +13,7 @@ func init() {
|
||||
bus.AddHandler("sql", GetAlertById)
|
||||
bus.AddHandler("sql", GetAlertsByDashboardId)
|
||||
bus.AddHandler("sql", GetAlertsByDashboardAndPanelId)
|
||||
bus.AddHandler("sql", DeleteAlertById)
|
||||
}
|
||||
|
||||
func GetAlertById(query *m.GetAlertByIdQuery) error {
|
||||
@@ -30,6 +31,16 @@ func GetAlertById(query *m.GetAlertByIdQuery) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeleteAlertById(cmd *m.DeleteAlertCommand) error {
|
||||
return inTransaction(func(sess *xorm.Session) error {
|
||||
if _, err := sess.Exec("DELETE FROM alert_rule WHERE id = ?", cmd.AlertId); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func GetAllAlertsForOrg(query *m.GetAlertsQuery) error {
|
||||
alerts := make([]m.AlertRule, 0)
|
||||
if err := x.Where("org_id = ?", query.OrgId).Find(&alerts); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user