Skip to content

Commit

Permalink
Consolidate percentage rule evaluation logs
Browse files Browse the repository at this point in the history
  • Loading branch information
z4kn4fein committed Aug 5, 2022
1 parent aea93d4 commit fda6f96
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/ConfigCatClient/Evaluate/RolloutEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,13 @@ private EvaluateResult EvaluateLogic(IDictionary<string, Setting> settings, stri

// evaluate variations

if (TryEvaluateVariations(setting.RolloutPercentageItems, key, user, out result))
if (TryEvaluateVariations(setting.RolloutPercentageItems, key, user, evaluateLog, out result))
{
evaluateLog.Log("Evaluate % option => user targeted");
evaluateLog.ReturnValue = result.Value.ToString();
evaluateLog.VariationId = result.VariationId;

result.SettingType = setting.SettingType;
return result;
}
else
{
evaluateLog.Log("Evaluate % option => user not targeted");
}
}
else if (setting.RolloutRules.Any() || setting.RolloutPercentageItems.Any())
{
Expand All @@ -139,7 +133,8 @@ private EvaluateResult EvaluateLogic(IDictionary<string, Setting> settings, stri
}
}

private static bool TryEvaluateVariations(ICollection<RolloutPercentageItem> rolloutPercentageItems, string key, User user, out EvaluateResult result)
private static bool TryEvaluateVariations<T>(ICollection<RolloutPercentageItem> rolloutPercentageItems, string key, User user,
EvaluateLogger<T> evaluateLog, out EvaluateResult result)
{
result = new EvaluateResult();

Expand All @@ -160,7 +155,7 @@ private static bool TryEvaluateVariations(ICollection<RolloutPercentageItem> rol
if (hashScale >= bucket) continue;
result.Value = variation.Value;
result.VariationId = variation.VariationId;

evaluateLog.Log($"Evaluating % options, '{key}' evaluated to '{variation.Value}'.");
return true;
}
}
Expand Down

0 comments on commit fda6f96

Please sign in to comment.