diff --git a/core/pkg/evaluator/fractional.go b/core/pkg/evaluator/fractional.go index 41adb4bc5..ecac855e4 100644 --- a/core/pkg/evaluator/fractional.go +++ b/core/pkg/evaluator/fractional.go @@ -64,19 +64,12 @@ func parseFractionalEvaluationData(values, data any) (string, []fractionalEvalua bucketBy = fmt.Sprintf("%s%s", properties.FlagKey, targetingKey) } - seed, ok := valuesArray[0].(string) - if ok { - valuesArray = valuesArray[1:] - } else { - seed = properties.FlagKey - } - feDistributions, err := parseFractionalEvaluationDistributions(valuesArray) if err != nil { return "", nil, err } - return fmt.Sprintf("%s%s", seed, bucketBy), feDistributions, nil + return bucketBy, feDistributions, nil } func parseFractionalEvaluationDistributions(values []any) ([]fractionalEvaluationDistribution, error) { diff --git a/core/pkg/evaluator/fractional_test.go b/core/pkg/evaluator/fractional_test.go index a3aacceb5..516362708 100644 --- a/core/pkg/evaluator/fractional_test.go +++ b/core/pkg/evaluator/fractional_test.go @@ -29,8 +29,7 @@ func TestFractionalEvaluation(t *testing.T) { }, { "fractional": [ - {"var": "email"}, - {"var": "$flagd.flagKey"}, + {"cat": [{"var": "$flagd.flagKey"}, {"var": "email"}]}, [ "red", 25 @@ -70,8 +69,7 @@ func TestFractionalEvaluation(t *testing.T) { }, { "fractional": [ - {"var": "email"}, - "my-seed", + {"cat": ["my-seed", {"var": "email"}]}, ["red",25], ["blue",25], ["green",25], @@ -226,59 +224,6 @@ func TestFractionalEvaluation(t *testing.T) { expectedValue: "#FF0000", expectedReason: model.TargetingMatchReason, }, - "ross@faas.com with default seed": { - flags: Flags{ - Flags: map[string]model.Flag{ - "headerColor": { - State: "ENABLED", - DefaultVariant: "red", - Variants: map[string]any{ - "red": "#FF0000", - "blue": "#0000FF", - "green": "#00FF00", - "yellow": "#FFFF00", - }, - Targeting: []byte(`{ - "if": [ - { - "in": ["@faas.com", { - "var": ["email"] - }] - }, - { - "fractional": [ - {"var": "email"}, - [ - "red", - 25 - ], - [ - "blue", - 25 - ], - [ - "green", - 25 - ], - [ - "yellow", - 25 - ] - ] - }, null - ] - }`), - }, - }, - }, - flagKey: "headerColor", - context: map[string]any{ - "email": "ross@faas.com", - }, - expectedVariant: "green", - expectedValue: "#00FF00", - expectedReason: model.TargetingMatchReason, - }, "non even split": { flags: Flags{ Flags: map[string]model.Flag{