mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 12:25:53 +02:00
refact pkg/database: dry decision count (#3586)
This commit is contained in:
parent
d46cef1bcb
commit
34e306505c
2 changed files with 14 additions and 66 deletions
|
@ -642,7 +642,7 @@ func GetDecisionsCount(params ...any) (any, error) {
|
|||
|
||||
ctx := context.TODO()
|
||||
|
||||
count, err := dbClient.CountDecisionsByValue(ctx, value)
|
||||
count, err := dbClient.CountDecisionsByValue(ctx, value, nil, false)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to get decisions count from value '%s'", value)
|
||||
return 0, nil //nolint:nilerr // This helper did not return an error before the move to expr.Function, we keep this behavior for backward compatibility
|
||||
|
@ -670,7 +670,7 @@ func GetDecisionsSinceCount(params ...any) (any, error) {
|
|||
ctx := context.TODO()
|
||||
sinceTime := time.Now().UTC().Add(-sinceDuration)
|
||||
|
||||
count, err := dbClient.CountDecisionsSinceByValue(ctx, value, sinceTime)
|
||||
count, err := dbClient.CountDecisionsByValue(ctx, value, &sinceTime, false)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to get decisions count from value '%s'", value)
|
||||
return 0, nil //nolint:nilerr // This helper did not return an error before the move to expr.Function, we keep this behavior for backward compatibility
|
||||
|
@ -689,7 +689,7 @@ func GetActiveDecisionsCount(params ...any) (any, error) {
|
|||
|
||||
ctx := context.TODO()
|
||||
|
||||
count, err := dbClient.CountActiveDecisionsByValue(ctx, value)
|
||||
count, err := dbClient.CountDecisionsByValue(ctx, value, nil, true)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to get active decisions count from value '%s'", value)
|
||||
return 0, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue