Alerting: Remove dead functionality from alert instance store (#55774)

* Update tests to use ListAlertInstances

* Drop the actual methods rather than just updating tests
This commit is contained in:
Alexander Weaver
2022-09-26 14:38:53 -05:00
committed by GitHub
parent a00879ae21
commit f11495a4c3
3 changed files with 13 additions and 57 deletions
@@ -2,46 +2,12 @@ package store
import (
"context"
"fmt"
"strings"
"github.com/grafana/grafana/pkg/services/ngalert/models"
"github.com/grafana/grafana/pkg/services/sqlstore"
)
// GetAlertInstance is a handler for retrieving an alert instance based on OrgId, AlertDefintionID, and
// the hash of the labels.
func (st DBstore) GetAlertInstance(ctx context.Context, cmd *models.GetAlertInstanceQuery) error {
return st.SQLStore.WithDbSession(ctx, func(sess *sqlstore.DBSession) error {
instance := models.AlertInstance{}
s := strings.Builder{}
s.WriteString(`SELECT * FROM alert_instance
WHERE
rule_org_id=? AND
rule_uid=? AND
labels_hash=?
`)
_, hash, err := cmd.Labels.StringAndHash()
if err != nil {
return err
}
params := append(make([]interface{}, 0), cmd.RuleOrgID, cmd.RuleUID, hash)
has, err := sess.SQL(s.String(), params...).Get(&instance)
if !has {
return fmt.Errorf("instance not found for labels %v (hash: %v), alert rule %v (org %v)", cmd.Labels, hash, cmd.RuleUID, cmd.RuleOrgID)
}
if err != nil {
return err
}
cmd.Result = &instance
return nil
})
}
// ListAlertInstances is a handler for retrieving alert instances within specific organisation
// based on various filters.
func (st DBstore) ListAlertInstances(ctx context.Context, cmd *models.ListAlertInstancesQuery) error {