mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Remove unused AlertRuleVersionWithPauseStatus (#82383)
Remove unused AlertRuleVersionWithPauseStatus
This commit is contained in:
parent
3f940f4da1
commit
ccb4533a86
@ -24,5 +24,5 @@ type RuleStore interface {
|
|||||||
DeleteAlertRulesByUID(ctx context.Context, orgID int64, ruleUID ...string) error
|
DeleteAlertRulesByUID(ctx context.Context, orgID int64, ruleUID ...string) error
|
||||||
|
|
||||||
// IncreaseVersionForAllRulesInNamespace Increases version for all rules that have specified namespace. Returns all rules that belong to the namespace
|
// IncreaseVersionForAllRulesInNamespace Increases version for all rules that have specified namespace. Returns all rules that belong to the namespace
|
||||||
IncreaseVersionForAllRulesInNamespace(ctx context.Context, orgID int64, namespaceUID string) ([]ngmodels.AlertRuleKeyWithVersionAndPauseStatus, error)
|
IncreaseVersionForAllRulesInNamespace(ctx context.Context, orgID int64, namespaceUID string) ([]ngmodels.AlertRuleKeyWithVersion, error)
|
||||||
}
|
}
|
||||||
|
@ -368,11 +368,6 @@ type AlertRuleKeyWithVersion struct {
|
|||||||
AlertRuleKey `xorm:"extends"`
|
AlertRuleKey `xorm:"extends"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AlertRuleKeyWithVersionAndPauseStatus struct {
|
|
||||||
IsPaused bool
|
|
||||||
AlertRuleKeyWithVersion `xorm:"extends"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AlertRuleKeyWithId struct {
|
type AlertRuleKeyWithId struct {
|
||||||
AlertRuleKey
|
AlertRuleKey
|
||||||
ID int64
|
ID int64
|
||||||
|
@ -72,8 +72,8 @@ func (st DBstore) DeleteAlertRulesByUID(ctx context.Context, orgID int64, ruleUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IncreaseVersionForAllRulesInNamespace Increases version for all rules that have specified namespace. Returns all rules that belong to the namespace
|
// IncreaseVersionForAllRulesInNamespace Increases version for all rules that have specified namespace. Returns all rules that belong to the namespace
|
||||||
func (st DBstore) IncreaseVersionForAllRulesInNamespace(ctx context.Context, orgID int64, namespaceUID string) ([]ngmodels.AlertRuleKeyWithVersionAndPauseStatus, error) {
|
func (st DBstore) IncreaseVersionForAllRulesInNamespace(ctx context.Context, orgID int64, namespaceUID string) ([]ngmodels.AlertRuleKeyWithVersion, error) {
|
||||||
var keys []ngmodels.AlertRuleKeyWithVersionAndPauseStatus
|
var keys []ngmodels.AlertRuleKeyWithVersion
|
||||||
err := st.SQLStore.WithTransactionalDbSession(ctx, func(sess *db.Session) error {
|
err := st.SQLStore.WithTransactionalDbSession(ctx, func(sess *db.Session) error {
|
||||||
now := TimeNow()
|
now := TimeNow()
|
||||||
_, err := sess.Exec("UPDATE alert_rule SET version = version + 1, updated = ? WHERE namespace_uid = ? AND org_id = ?", now, namespaceUID, orgID)
|
_, err := sess.Exec("UPDATE alert_rule SET version = version + 1, updated = ? WHERE namespace_uid = ? AND org_id = ?", now, namespaceUID, orgID)
|
||||||
|
@ -315,7 +315,7 @@ func (f *RuleStore) UpdateRuleGroup(ctx context.Context, orgID int64, namespaceU
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *RuleStore) IncreaseVersionForAllRulesInNamespace(_ context.Context, orgID int64, namespaceUID string) ([]models.AlertRuleKeyWithVersionAndPauseStatus, error) {
|
func (f *RuleStore) IncreaseVersionForAllRulesInNamespace(_ context.Context, orgID int64, namespaceUID string) ([]models.AlertRuleKeyWithVersion, error) {
|
||||||
f.mtx.Lock()
|
f.mtx.Lock()
|
||||||
defer f.mtx.Unlock()
|
defer f.mtx.Unlock()
|
||||||
|
|
||||||
@ -324,18 +324,15 @@ func (f *RuleStore) IncreaseVersionForAllRulesInNamespace(_ context.Context, org
|
|||||||
Params: []any{orgID, namespaceUID},
|
Params: []any{orgID, namespaceUID},
|
||||||
})
|
})
|
||||||
|
|
||||||
var result []models.AlertRuleKeyWithVersionAndPauseStatus
|
var result []models.AlertRuleKeyWithVersion
|
||||||
|
|
||||||
for _, rule := range f.Rules[orgID] {
|
for _, rule := range f.Rules[orgID] {
|
||||||
if rule.NamespaceUID == namespaceUID && rule.OrgID == orgID {
|
if rule.NamespaceUID == namespaceUID && rule.OrgID == orgID {
|
||||||
rule.Version++
|
rule.Version++
|
||||||
rule.Updated = time.Now()
|
rule.Updated = time.Now()
|
||||||
result = append(result, models.AlertRuleKeyWithVersionAndPauseStatus{
|
result = append(result, models.AlertRuleKeyWithVersion{
|
||||||
IsPaused: rule.IsPaused,
|
|
||||||
AlertRuleKeyWithVersion: models.AlertRuleKeyWithVersion{
|
|
||||||
Version: rule.Version,
|
Version: rule.Version,
|
||||||
AlertRuleKey: rule.GetKey(),
|
AlertRuleKey: rule.GetKey(),
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user