Skip to content

Commit

Permalink
Added fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Varun Rathore committed Nov 6, 2024
1 parent 55f2a0a commit ad0e13c
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 109 deletions.
8 changes: 6 additions & 2 deletions firebase_admin/remote_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,19 @@ def evaluate_percent_condition(self, percent_condition,
else:
norm_percent_upper_bound = 0
norm_percent_lower_bound = 0
if micro_percent:
norm_micro_percent = micro_percent
else:
norm_micro_percent = 0
seed_prefix = f"{seed}." if seed else ""
string_to_hash = f"{seed_prefix}{context.get('randomization_id')}"

hash64 = self.hash_seeded_randomization_id(string_to_hash)
instance_micro_percentile = hash64 % (100 * 1000000)
if percent_operator == PercentConditionOperator.LESS_OR_EQUAL:
return instance_micro_percentile <= micro_percent
return instance_micro_percentile <= norm_micro_percent
if percent_operator == PercentConditionOperator.GREATER_THAN:
return instance_micro_percentile > micro_percent
return instance_micro_percentile > norm_micro_percent
if percent_operator == PercentConditionOperator.BETWEEN:
return norm_percent_lower_bound < instance_micro_percentile <= norm_percent_upper_bound
logger.warning("Unknown percent operator: %s", percent_operator)
Expand Down
Loading

0 comments on commit ad0e13c

Please sign in to comment.