@@ -43,7 +43,7 @@ class UserProfile:
4343 def __init__ (
4444 self ,
4545 user_id : str ,
46- experiment_bucket_map : Optional [dict [str , Union [ Decision , dict [str , str ]]]] = None ,
46+ experiment_bucket_map : Optional [dict [str , dict [str , Optional [ str ]]]] = None ,
4747 ** kwargs : Any
4848 ):
4949 self .user_id = user_id
@@ -146,18 +146,21 @@ def load_user_profile(self, reasons: Optional[list[str]] = [],
146146 self .user_profile = UserProfile (self .user_id , {})
147147
148148 def update_user_profile (self , experiment : Experiment , variation : Variation ) -> None :
149- if experiment .id in self .user_profile .experiment_bucket_map :
150- decision = self .user_profile .experiment_bucket_map [experiment .id ]
151- if isinstance (decision , decision_service .Decision ):
152- decision = decision_service .Decision (
153- experiment = decision .experiment ,
154- variation = variation ,
155- source = decision .source
156- )
157- else :
158- decision = decision_service .Decision (experiment = None , variation = variation , source = None )
159-
160- self .user_profile .experiment_bucket_map [experiment .id ] = decision
149+ variation_id = variation .id
150+ experiment_id = experiment .id
151+ self .user_profile .save_variation_for_experiment (experiment_id , variation_id )
152+ # if experiment.id in self.user_profile.experiment_bucket_map:
153+ # decision = self.user_profile.experiment_bucket_map[experiment.id]
154+ # if isinstance(decision, decision_service.Decision):
155+ # decision = decision_service.Decision(
156+ # experiment=decision.experiment,
157+ # variation=variation,
158+ # source=decision.source
159+ # )
160+ # else:
161+ # decision = decision_service.Decision(experiment=None, variation=variation, source=None)
162+
163+ # self.user_profile.experiment_bucket_map[experiment.id] = decision
161164 self .profile_updated = True
162165
163166 def save_user_profile (self , error_handler : Optional [BaseErrorHandler ] = None ) -> None :
0 commit comments