|
@@ -13,6 +13,7 @@ func init() {
|
|
|
bus.AddHandler("sql", GetAlertById)
|
|
bus.AddHandler("sql", GetAlertById)
|
|
|
bus.AddHandler("sql", GetAlertsByDashboardId)
|
|
bus.AddHandler("sql", GetAlertsByDashboardId)
|
|
|
bus.AddHandler("sql", GetAlertsByDashboardAndPanelId)
|
|
bus.AddHandler("sql", GetAlertsByDashboardAndPanelId)
|
|
|
|
|
+ bus.AddHandler("sql", DeleteAlertById)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func GetAlertById(query *m.GetAlertByIdQuery) error {
|
|
func GetAlertById(query *m.GetAlertByIdQuery) error {
|
|
@@ -30,6 +31,16 @@ func GetAlertById(query *m.GetAlertByIdQuery) error {
|
|
|
return nil
|
|
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 {
|
|
func GetAllAlertsForOrg(query *m.GetAlertsQuery) error {
|
|
|
alerts := make([]m.AlertRule, 0)
|
|
alerts := make([]m.AlertRule, 0)
|
|
|
if err := x.Where("org_id = ?", query.OrgId).Find(&alerts); err != nil {
|
|
if err := x.Where("org_id = ?", query.OrgId).Find(&alerts); err != nil {
|