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 "spec/engine-test-data"]
path = spec/engine-test-data
url = git@github.com:Flagsmith/engine-test-data.git
branch = main
branch = v3.5.0
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ GEM
ruby-progressbar (1.13.0)
semantic (1.6.1)
unicode-display_width (2.5.0)
uri (0.13.2)
uri (1.1.1)

PLATFORMS
ruby
Expand Down
14 changes: 12 additions & 2 deletions lib/flagsmith/engine/segments/evaluator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,18 @@ def traits_match_segment_condition_from_context(condition, segment_key, context)
end

def handle_percentage_split(condition, segment_key, context)
context_value_key = get_context_value(condition[:property], context) || get_identity_key_from_context(context)
hashed_percentage = hashed_percentage_for_object_ids([segment_key, context_value_key])
split_key = if condition[:property].nil? || condition[:property].empty?
# No property specified - use identity key
get_identity_key_from_context(context)
else
# Property specified - must exist in context
get_context_value(condition[:property], context)
end

# If split_key is nil, condition doesn't match
return false if split_key.nil?

hashed_percentage = hashed_percentage_for_object_ids([segment_key, split_key])
hashed_percentage <= condition[:value].to_f
end

Expand Down