Chore: Sql store split for legacy alerting (#52901)
Moves ~20 sqlstore methods for legacy alerting out of sqlstore (sqlstore.Store interface) and into alerting.
This commit is contained in:
+7
-7
@@ -28,7 +28,7 @@ func (hs *HTTPServer) ValidateOrgAlert(c *models.ReqContext) {
|
||||
}
|
||||
query := models.GetAlertByIdQuery{Id: id}
|
||||
|
||||
if err := hs.SQLStore.GetAlertById(c.Req.Context(), &query); err != nil {
|
||||
if err := hs.AlertEngine.AlertStore.GetAlertById(c.Req.Context(), &query); err != nil {
|
||||
c.JsonApiErr(404, "Alert not found", nil)
|
||||
return
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func (hs *HTTPServer) GetAlertStatesForDashboard(c *models.ReqContext) response.
|
||||
DashboardId: c.QueryInt64("dashboardId"),
|
||||
}
|
||||
|
||||
if err := hs.SQLStore.GetAlertStatesForDashboard(c.Req.Context(), &query); err != nil {
|
||||
if err := hs.AlertEngine.AlertStore.GetAlertStatesForDashboard(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to fetch alert states", err)
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ func (hs *HTTPServer) GetAlerts(c *models.ReqContext) response.Response {
|
||||
query.State = states
|
||||
}
|
||||
|
||||
if err := hs.SQLStore.HandleAlertsQuery(c.Req.Context(), &query); err != nil {
|
||||
if err := hs.AlertEngine.AlertStore.HandleAlertsQuery(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "List alerts failed", err)
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ func (hs *HTTPServer) GetAlert(c *models.ReqContext) response.Response {
|
||||
}
|
||||
query := models.GetAlertByIdQuery{Id: id}
|
||||
|
||||
if err := hs.SQLStore.GetAlertById(c.Req.Context(), &query); err != nil {
|
||||
if err := hs.AlertEngine.AlertStore.GetAlertById(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "List alerts failed", err)
|
||||
}
|
||||
|
||||
@@ -689,7 +689,7 @@ func (hs *HTTPServer) PauseAlert(legacyAlertingEnabled *bool) func(c *models.Req
|
||||
result["alertId"] = alertID
|
||||
|
||||
query := models.GetAlertByIdQuery{Id: alertID}
|
||||
if err := hs.SQLStore.GetAlertById(c.Req.Context(), &query); err != nil {
|
||||
if err := hs.AlertEngine.AlertStore.GetAlertById(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Get Alert failed", err)
|
||||
}
|
||||
|
||||
@@ -719,7 +719,7 @@ func (hs *HTTPServer) PauseAlert(legacyAlertingEnabled *bool) func(c *models.Req
|
||||
Paused: dto.Paused,
|
||||
}
|
||||
|
||||
if err := hs.SQLStore.PauseAlert(c.Req.Context(), &cmd); err != nil {
|
||||
if err := hs.AlertEngine.AlertStore.PauseAlert(c.Req.Context(), &cmd); err != nil {
|
||||
return response.Error(500, "", err)
|
||||
}
|
||||
|
||||
@@ -764,7 +764,7 @@ func (hs *HTTPServer) PauseAllAlerts(legacyAlertingEnabled *bool) func(c *models
|
||||
Paused: dto.Paused,
|
||||
}
|
||||
|
||||
if err := hs.SQLStore.PauseAllAlerts(c.Req.Context(), &updateCmd); err != nil {
|
||||
if err := hs.AlertEngine.AlertStore.PauseAllAlerts(c.Req.Context(), &updateCmd); err != nil {
|
||||
return response.Error(500, "Failed to pause alerts", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user