mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Check if pagination token is greater than or equal to (#99576)
Use goe for token comparison
This commit is contained in:
parent
cc09f38421
commit
848ef72100
@ -352,7 +352,7 @@ func PrepareRuleGroupStatuses(log log.Logger, manager state.AlertInstanceManager
|
||||
}
|
||||
|
||||
if nextToken != "" && !foundToken {
|
||||
if nextToken != getRuleGroupNextToken(rg.Folder, rg.GroupKey.RuleGroup) {
|
||||
if !tokenGreaterThanOrEqual(getRuleGroupNextToken(rg.Folder, rg.GroupKey.RuleGroup), nextToken) {
|
||||
continue
|
||||
}
|
||||
foundToken = true
|
||||
@ -394,6 +394,14 @@ func getRuleGroupNextToken(namespace, group string) string {
|
||||
return base64.URLEncoding.EncodeToString([]byte(namespace + "/" + group))
|
||||
}
|
||||
|
||||
// Returns true if tokenA >= tokenB
|
||||
func tokenGreaterThanOrEqual(tokenA string, tokenB string) bool {
|
||||
decodedTokenA, _ := base64.URLEncoding.DecodeString(tokenA)
|
||||
decodedTokenB, _ := base64.URLEncoding.DecodeString(tokenB)
|
||||
|
||||
return string(decodedTokenA) >= string(decodedTokenB)
|
||||
}
|
||||
|
||||
type ruleGroup struct {
|
||||
Folder string
|
||||
GroupKey ngmodels.AlertRuleGroupKey
|
||||
|
Loading…
Reference in New Issue
Block a user