func GetDecisionsSinceCount(value string, since string) int {
(params ...any)
| 768 | |
| 769 | // func GetDecisionsSinceCount(value string, since string) int { |
| 770 | func GetDecisionsSinceCount(params ...any) (any, error) { |
| 771 | value := params[0].(string) |
| 772 | since := params[1].(string) |
| 773 | |
| 774 | if dbClient == nil { |
| 775 | log.Error("No database config to call GetDecisionsSinceCount()") |
| 776 | return 0, nil |
| 777 | } |
| 778 | |
| 779 | sinceDuration, err := cstime.ParseDurationWithDays(since) |
| 780 | if err != nil { |
| 781 | log.Errorf("Failed to parse since parameter '%s' : %s", since, err) |
| 782 | return 0, nil |
| 783 | } |
| 784 | |
| 785 | ctx := context.TODO() |
| 786 | sinceTime := time.Now().UTC().Add(-sinceDuration) |
| 787 | |
| 788 | count, err := dbClient.CountDecisionsByValue(ctx, value, &sinceTime, false) |
| 789 | if err != nil { |
| 790 | log.Errorf("Failed to get decisions count from value '%s'", value) |
| 791 | 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 |
| 792 | } |
| 793 | |
| 794 | return count, nil |
| 795 | } |
| 796 | |
| 797 | func GetActiveDecisionsCount(params ...any) (any, error) { |
| 798 | value := params[0].(string) |
nothing calls this directly
no test coverage detected
searching dependent graphs…