format
This commit is contained in:
@@ -3,6 +3,7 @@ package promotions
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -346,10 +347,8 @@ func evaluateBaseCondition(b BaseCondition, ctx *PromotionEvalContext) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func evalAnyItemMatch(pred func(PromotionItem) bool, b BaseCondition, ctx *PromotionEvalContext) bool {
|
func evalAnyItemMatch(pred func(PromotionItem) bool, b BaseCondition, ctx *PromotionEvalContext) bool {
|
||||||
for _, it := range ctx.Items {
|
if slices.ContainsFunc(ctx.Items, pred) {
|
||||||
if pred(it) {
|
return true
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
switch normalizeOperator(string(b.Operator)) {
|
switch normalizeOperator(string(b.Operator)) {
|
||||||
case string(OpNotIn), string(OpNotContains):
|
case string(OpNotIn), string(OpNotContains):
|
||||||
@@ -704,12 +703,7 @@ func normalizeLogicOperator(op string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func sliceFloatContains(list []float64, v float64) bool {
|
func sliceFloatContains(list []float64, v float64) bool {
|
||||||
for _, x := range list {
|
return slices.Contains(list, v)
|
||||||
if x == v {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------
|
// ----------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user