feat(alerting): add support for deleting alert rules

This commit is contained in:
bergquist
2016-05-02 16:07:19 +02:00
parent a573d2504c
commit 743a6fa37c
5 changed files with 46 additions and 2 deletions

View File

@@ -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 {