-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refact: Refactored Forced decision #287
Refact: Refactored Forced decision #287
Conversation
…gs and other minor issue due to which tests were failing
# Conflicts: # OptimizelySDK/Config/DatafileProjectConfig.cs # OptimizelySDK/Event/Builder/EventBuilder.cs
} | ||
|
||
public OptimizelyUserContext(Optimizely optimizely, string userId, UserAttributes userAttributes, Dictionary<string, OptimizelyForcedDecision> forcedDecisions, IErrorHandler errorHandler, ILogger logger) | ||
public OptimizelyUserContext(Optimizely optimizely, string userId, UserAttributes userAttributes, ForcedDecisionsStore forcedDecisionsStore, IErrorHandler errorHandler, ILogger logger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this constructor method? @jaeopt a question for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor looks good! Some changes suggested.
Logger = logger; | ||
Optimizely = optimizely; | ||
Attributes = userAttributes ?? new UserAttributes(); | ||
ForcedDecisionsMap = forcedDecisions ?? new Dictionary<string, OptimizelyForcedDecision>(); | ||
ForcedDecisionsStore = forcedDecisionsStore ?? new ForcedDecisionsStore(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need make a copy of forcedDecisionsStore (just like "attributes" copy) since they can be changed after user context copied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also consider optimization as well - most user contexts do not use ForcedDecision, so we can avoid instantiating/copying FDStore when not used at all.
java-sdk impl as a reference https://github.com/optimizely/java-sdk/blob/master/core-api/src/main/java/com/optimizely/ab/OptimizelyUserContext.java
LGTM, appreciate the changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM other than the missing else
{ | ||
copiedForcedDecisionsStore = ForcedDecisionsStore.NullForcedDecision(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'else' missing
Summary
Test plan
All FSC and unit tests should pass
Issues