|
2 | 2 |
|
3 | 3 | module Flagsmith |
4 | 4 | module Engine |
5 | | - module EvaluationContext |
| 5 | + module Evaluation |
6 | 6 | module Mappers |
7 | 7 | STRONGEST_PRIORITY = Float::INFINITY |
8 | 8 | WEAKEST_PRIORITY = -Float::INFINITY |
@@ -55,7 +55,8 @@ def self.map_environment_model_to_evaluation_context(environment) |
55 | 55 | } |
56 | 56 |
|
57 | 57 | feature_hash[:variants] = variants if variants |
58 | | - feature_hash[:priority] = fs.feature_segment.priority if fs.feature_segment&.priority |
| 58 | + priority = fs.feature_segment&.priority |
| 59 | + feature_hash[:priority] = priority unless priority.nil? |
59 | 60 | feature_hash[:metadata] = { flagsmith_id: fs.feature.id } |
60 | 61 |
|
61 | 62 | features[fs.feature.name] = feature_hash |
@@ -138,17 +139,9 @@ def self.map_segment_rule_model_to_rule(rule) |
138 | 139 | } |
139 | 140 |
|
140 | 141 | # Map conditions if present |
141 | | - result[:conditions] = if rule.conditions&.any? |
142 | | - rule.conditions.map do |condition| |
143 | | - { |
144 | | - property: condition.property, |
145 | | - operator: condition.operator, |
146 | | - value: condition.value |
147 | | - } |
148 | | - end |
149 | | - else |
150 | | - [] |
151 | | - end |
| 142 | + result[:conditions] = (rule.conditions || []).map do |condition| |
| 143 | + { property: condition.property, operator: condition.operator, value: condition.value } |
| 144 | + end |
152 | 145 |
|
153 | 146 | result[:rules] = if rule.rules&.any? |
154 | 147 | rule.rules.map { |nested_rule| map_segment_rule_model_to_rule(nested_rule) } |
@@ -188,7 +181,7 @@ def self.map_identity_overrides_to_segments(identity_overrides) |
188 | 181 | end |
189 | 182 |
|
190 | 183 | # Create hash of the overrides to group identities with same overrides |
191 | | - overrides_hash = overrides_key.hash |
| 184 | + overrides_hash = Digest::SHA1.hexdigest(overrides_key.inspect) |
192 | 185 |
|
193 | 186 | features_to_identifiers[overrides_hash] ||= { identifiers: [], overrides: overrides_key } |
194 | 187 | features_to_identifiers[overrides_hash][:identifiers] << identity.identifier |
|
0 commit comments