feat(alerting): remove orgid from alertrule query

This commit is contained in:
bergquist
2016-06-03 15:24:53 +02:00
parent 2cf797b567
commit 6a49d4ed6b
3 changed files with 20 additions and 6 deletions

View File

@@ -16,6 +16,7 @@ func init() {
bus.AddHandler("sql", HandleAlertsQuery)
bus.AddHandler("sql", GetAlertById)
bus.AddHandler("sql", DeleteAlertById)
bus.AddHandler("sql", GetAllAlertQueryHandler)
}
func GetAlertById(query *m.GetAlertByIdQuery) error {
@@ -32,6 +33,17 @@ func GetAlertById(query *m.GetAlertByIdQuery) error {
return nil
}
func GetAllAlertQueryHandler(query *m.GetAllAlertsQuery) error {
var alerts []m.AlertRule
err := x.Sql("select * from alert_rule").Find(&alerts)
if err != nil {
return err
}
query.Result = alerts
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 {