Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "flagengine/engine-test-data"]
path = flagengine/engine-test-data
url = git@github.com:Flagsmith/engine-test-data.git
tag = v3.5.0
tag = v3.7.0
28 changes: 25 additions & 3 deletions flagengine/engine_eval/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,34 @@ func contextMatchesSegmentRule(ec *EngineEvaluationContext, segmentRule *Segment
}
}

for i := range segmentRule.Rules {
if !contextMatchesSegmentRule(ec, &segmentRule.Rules[i], segmentKey) {
return matchesSubRulesByRuleType(ec, segmentRule.Rules, segmentRule.Type, segmentKey)
}

// matchesSubRulesByRuleType evaluates sub-rules using the parent rule's type (ALL/ANY/NONE).
func matchesSubRulesByRuleType(ec *EngineEvaluationContext, subRules []SegmentRule, ruleType Type, segmentKey string) bool {
if len(subRules) == 0 {
return true
}
for i := range subRules {
subRuleMatches := contextMatchesSegmentRule(ec, &subRules[i], segmentKey)
switch ruleType {
case All:
if !subRuleMatches {
return false
}
case None:
if subRuleMatches {
return false
}
case Any:
if subRuleMatches {
return true
}
default:
return false
}
}
return true
return ruleType != Any
}

func matchPercentageSplit(ec *EngineEvaluationContext, segmentCondition *Condition, segmentKey string, contextValue ContextValue) bool {
Expand Down
Loading