@@ -55,7 +55,8 @@ def self.map_environment_model_to_evaluation_context(environment)
5555 }
5656
5757 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?
5960 feature_hash [ :metadata ] = { flagsmith_id : fs . feature . id }
6061
6162 features [ fs . feature . name ] = feature_hash
@@ -138,17 +139,9 @@ def self.map_segment_rule_model_to_rule(rule)
138139 }
139140
140141 # 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
152145
153146 result [ :rules ] = if rule . rules &.any?
154147 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)
188181 end
189182
190183 # 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 )
192185
193186 features_to_identifiers [ overrides_hash ] ||= { identifiers : [ ] , overrides : overrides_key }
194187 features_to_identifiers [ overrides_hash ] [ :identifiers ] << identity . identifier
0 commit comments