@@ -132,8 +132,7 @@ public DecisionResponse<Variation> getVariation(@Nonnull Experiment experiment,
132
132
133
133
if (variation != null ) {
134
134
if (userProfileTracker != null ) {
135
- updateUserProfile (experiment , variation , userProfileTracker .userProfile );
136
- userProfileTracker .profileUpdated = true ;
135
+ userProfileTracker .updateUserProfile (experiment , variation );
137
136
} else {
138
137
logger .debug ("This decision will not be saved since the UserProfileService is null." );
139
138
}
@@ -233,14 +232,32 @@ private UserProfile getUserProfile(String userId, DecisionReasons reasons) {
233
232
return userProfile ;
234
233
}
235
234
236
- static class UserProfileTracker {
235
+ class UserProfileTracker {
237
236
public UserProfile userProfile ;
238
237
public boolean profileUpdated ;
239
238
240
239
UserProfileTracker (UserProfile userProfile , boolean profileUpdated ) {
241
240
this .userProfile = userProfile ;
242
241
this .profileUpdated = profileUpdated ;
243
242
}
243
+
244
+ void updateUserProfile (@ Nonnull Experiment experiment ,
245
+ @ Nonnull Variation variation ) {
246
+
247
+ String experimentId = experiment .getId ();
248
+ String variationId = variation .getId ();
249
+ Decision decision ;
250
+ if (userProfile .experimentBucketMap .containsKey (experimentId )) {
251
+ decision = userProfile .experimentBucketMap .get (experimentId );
252
+ decision .variationId = variationId ;
253
+ } else {
254
+ decision = new Decision (variationId );
255
+ }
256
+ userProfile .experimentBucketMap .put (experimentId , decision );
257
+ profileUpdated = true ;
258
+ logger .info ("Updated variation \" {}\" of experiment \" {}\" for user \" {}\" ." ,
259
+ variationId , experimentId , userProfile .userId );
260
+ }
244
261
}
245
262
246
263
/**
@@ -495,31 +512,6 @@ DecisionResponse<Variation> getStoredVariation(@Nonnull Experiment experiment,
495
512
}
496
513
}
497
514
498
- /**
499
- * Save a {@link Variation} of an {@link Experiment} for a user in the {@link UserProfileService}.
500
- *
501
- * @param experiment The experiment the user was buck
502
- * @param variation The Variation to save.
503
- * @param userProfile A {@link UserProfile} instance of the user information.
504
- */
505
- void updateUserProfile (@ Nonnull Experiment experiment ,
506
- @ Nonnull Variation variation ,
507
- @ Nonnull UserProfile userProfile ) {
508
-
509
- String experimentId = experiment .getId ();
510
- String variationId = variation .getId ();
511
- Decision decision ;
512
- if (userProfile .experimentBucketMap .containsKey (experimentId )) {
513
- decision = userProfile .experimentBucketMap .get (experimentId );
514
- decision .variationId = variationId ;
515
- } else {
516
- decision = new Decision (variationId );
517
- }
518
- userProfile .experimentBucketMap .put (experimentId , decision );
519
- logger .info ("Updated variation \" {}\" of experiment \" {}\" for user \" {}\" ." ,
520
- variationId , experimentId , userProfile .userId );
521
- }
522
-
523
515
/**
524
516
* Save a {@link Variation} of an {@link Experiment} for a user in the {@link UserProfileService}.
525
517
*
0 commit comments