Skip to content

Commit 07664a8

Browse files
committed
refactored and removed commented code
1 parent 725915d commit 07664a8

File tree

3 files changed

+6
-62
lines changed

3 files changed

+6
-62
lines changed

OptimizelySDK/Bucketing/DecisionService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ public virtual Result<FeatureDecision> GetVariationForFeatureExperiment(FeatureF
568568
decisionVariation = decisionResponse.ResultObject;
569569
}
570570

571-
if (decisionVariation?.Id != null)
571+
if (!string.IsNullOrEmpty(decisionVariation?.Id))
572572
{
573573
Logger.Log(LogLevel.INFO, reasons.AddInfo($"The user \"{userId}\" is bucketed into experiment \"{experiment.Key}\" of feature \"{featureFlag.Key}\"."));
574574

OptimizelySDK/Config/DatafileProjectConfig.cs

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,8 @@ private Dictionary<string, Dictionary<string, Variation>> _VariationIdMap
205205
private Dictionary<string, List<string>> ExperimentFeatureMap = new Dictionary<string, List<string>>();
206206

207207
/// <summary>
208-
/// Associated array of flags to variations key map.
208+
/// Associated dictionary of flags to variations key value.
209209
/// </summary>
210-
211210
private Dictionary<string, Dictionary<string, Variation>> _FlagVariationMap = new Dictionary<string, Dictionary<string, Variation>>();
212211
public Dictionary<string, Dictionary<string, Variation>> FlagVariationMap { get { return _FlagVariationMap; } }
213212

@@ -355,18 +354,15 @@ private void Initialize()
355354
}
356355
}
357356

358-
var variationsDict = new Dictionary<string, List<Variation>>();
359-
///TODO: Need to remove.
360357
var flagToVariationsMap = new Dictionary<string, Dictionary<string, Variation>>();
361358
// Adding experiments in experiment-feature map and flag variation map to use.
362359
foreach (var feature in FeatureFlags)
363360
{
364-
/// TODO: give proper name.
365-
var flagVariationToVariationDict = new Dictionary<string, Variation>();
361+
var variationKeyToVariationDict = new Dictionary<string, Variation>();
366362
foreach (var experimentId in feature.ExperimentIds ?? new List<string>())
367363
{
368364
foreach (var variationDictKV in ExperimentIdMap[experimentId].VariationKeyToVariationMap) {
369-
flagVariationToVariationDict[variationDictKV.Key] = variationDictKV.Value;
365+
variationKeyToVariationDict[variationDictKV.Key] = variationDictKV.Value;
370366
}
371367

372368
if (ExperimentFeatureMap.ContainsKey(experimentId))
@@ -381,42 +377,15 @@ private void Initialize()
381377
if (RolloutIdMap.TryGetValue(feature.RolloutId, out var rolloutRules)) {
382378
var rolloutRulesVariations = rolloutRules.Experiments.SelectMany(ex => ex.Variations);
383379
foreach (var rolloutRuleVariation in rolloutRulesVariations) {
384-
flagVariationToVariationDict[rolloutRuleVariation.Key] = rolloutRuleVariation;
380+
variationKeyToVariationDict[rolloutRuleVariation.Key] = rolloutRuleVariation;
385381
}
386382
}
387383

388-
flagToVariationsMap[feature.Key] = flagVariationToVariationDict;
384+
flagToVariationsMap[feature.Key] = variationKeyToVariationDict;
389385
}
390386
_FlagVariationMap = flagToVariationsMap;
391387
}
392388

393-
/// <summary>
394-
/// Retrieves all the rules for a given feature flag
395-
/// </summary>
396-
/// <param name="flag">Feature flag to use</param>
397-
/// <returns>A list of experiments</returns>
398-
//private List<Experiment> GetAllRulesForFlag(FeatureFlag flag)
399-
//{
400-
// var rules = new List<Experiment>();
401-
402-
// RolloutIdMap.TryGetValue(flag.RolloutId, out var rollout);
403-
404-
// foreach (var expId in flag.ExperimentIds)
405-
// {
406-
// if (ExperimentIdMap.TryGetValue(expId, out var rule))
407-
// {
408-
// rules.Add(rule);
409-
// }
410-
// }
411-
412-
// if (rollout != null)
413-
// {
414-
// rules.AddRange(rollout.Experiments);
415-
// }
416-
417-
// return rules;
418-
//}
419-
420389
/// <summary>
421390
/// Parse datafile string to create ProjectConfig instance.
422391
/// </summary>

OptimizelySDK/Optimizely.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -445,31 +445,6 @@ public Variation GetForcedVariation(string experimentKey, string userId)
445445
return DecisionService.GetForcedVariation(experimentKey, userId, config).ResultObject;
446446
}
447447

448-
/// <summary>
449-
/// Gets a variation based on flagKey and variationKey
450-
/// </summary>
451-
/// <param name="flagKey">The flag key for the variation</param>
452-
/// <param name="variationKey">The variation key for the variation</param>
453-
/// <returns>Returns a variation based on flagKey and variationKey, otherwise null</returns>
454-
//public Variation GetFlagVariationByKey(string flagKey, string variationKey)
455-
//{
456-
// var config = ProjectConfigManager?.GetConfig();
457-
458-
// if (config == null)
459-
// {
460-
// return null;
461-
// }
462-
463-
// if (config.FlagVariationMap.TryGetValue(flagKey, out var variationsKeyMap))
464-
// {
465-
466-
// variationsKeyMap.TryGetValue(variationKey, out var variation);
467-
// return variation;
468-
// }
469-
470-
// return null;
471-
//}
472-
473448
#region FeatureFlag APIs
474449

475450
/// <summary>

0 commit comments

Comments
 (0)