Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFM-11657 Sort serving rules and flag rules in cache code #41

Merged
merged 1 commit into from
Jun 28, 2024
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
7 changes: 1 addition & 6 deletions lib/ff/ruby/server/sdk/api/evaluator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ def is_target_included_or_excluded_in_segment(segment_list, target)
if new_serving_rules != nil && !new_serving_rules.empty?
# Use enhanced rules first if they're available

new_serving_rules.sort_by!(&:priority)
new_serving_rules.each do |serving_rule|
if evaluate_clauses_v2(serving_rule.clauses, target)
return true
Expand Down Expand Up @@ -339,11 +338,7 @@ def evaluate_rules(serving_rules, target)
return nil
end

sorted = serving_rules.sort do |a, b|
b.priority <=> a.priority
end

sorted.each do |rule|
serving_rules.each do |rule|
next unless evaluate_rule(rule, target)

if rule.serve.distribution != nil
Expand Down
14 changes: 14 additions & 0 deletions lib/ff/ruby/server/sdk/api/storage_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def set_flag(identifier, feature_config)
return
end

sort_flag_rules(feature_config)
flag_key = format_flag_key(identifier)

if @store != nil
Expand Down Expand Up @@ -141,6 +142,7 @@ def set_segment(identifier, segment)
return
end

sort_segment_serving_rules(segment)
segment_key = format_segment_key(identifier)

if @store != nil
Expand Down Expand Up @@ -240,6 +242,18 @@ def is_flag_outdated(identifier, new_feature_config)
false
end

def sort_flag_rules(flag)
if flag.rules && flag.rules.length > 1
flag.rules.sort_by!(&:priority)
end
end

def sort_segment_serving_rules(segment)
if segment.serving_rules && segment.serving_rules.length > 1
segment.serving_rules.sort_by!(&:priority)
end
end

def is_segment_outdated(identifier, new_segment)

segment = get_segment(identifier, false)
Expand Down
2 changes: 1 addition & 1 deletion lib/ff/ruby/server/sdk/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Ruby
module Server
module Sdk

VERSION = "1.3.0"
VERSION = "1.3.1"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion scripts/sdk_specs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

export ff_ruby_sdk="ff-ruby-server-sdk"
export ff_ruby_sdk_version="1.3.0"
export ff_ruby_sdk_version="1.3.1"