Skip to content

Commit

Permalink
optimizely/user_profile.py -> Reverted back to variation ID retrieval…
Browse files Browse the repository at this point in the history
… logic.
  • Loading branch information
FarhanAnjum-opti committed Nov 26, 2024
1 parent 6387ca2 commit 8359498
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions optimizely/user_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from typing import Any, Optional
from sys import version_info
from . import logger as _logging
from . import decision_service

if version_info < (3, 8):
from typing_extensions import Final
else:
Expand Down Expand Up @@ -60,14 +60,7 @@ def get_variation_for_experiment(self, experiment_id: str) -> Optional[str]:
Returns:
Variation ID corresponding to the experiment. None if no decision available.
"""
experiment_data = self.experiment_bucket_map.get(experiment_id)

if isinstance(experiment_data, decision_service.Decision):
return experiment_data.variation.id if experiment_data.variation is not None else None
elif isinstance(experiment_data, dict):
return experiment_data.get(self.VARIATION_ID_KEY)

return None
return self.experiment_bucket_map.get(experiment_id, {self.VARIATION_ID_KEY: None}).get(self.VARIATION_ID_KEY)

def save_variation_for_experiment(self, experiment_id: str, variation_id: str) -> None:
""" Helper method to save new experiment/variation as part of the user's profile.
Expand Down

0 comments on commit 8359498

Please sign in to comment.