-
Notifications
You must be signed in to change notification settings - Fork 18
feat(OptimizelyConfig): Add new fields to OptimizelyConfig. #322
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
Conversation
|
|
||
| rolloutMap := mappers.MapRollouts(datafile.Rollouts) | ||
| rollouts, rolloutMap := mappers.MapRollouts(datafile.Rollouts) | ||
| events := []entities.Event{} |
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.
move this code to MapEvents?
| featureMap := mappers.MapFeatures(datafile.FeatureFlags, rolloutMap, experimentMap) | ||
| features, featureMap := mappers.MapFeatures(datafile.FeatureFlags, rolloutMap, experimentMap) | ||
| attributes := []entities.Attribute{} | ||
| for _, attribute := range datafile.Attributes { |
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.
same here.
| var json = jsoniter.ConfigCompatibleWithStandardLibrary | ||
|
|
||
| // GetDefaultOperators returns default conditional operators | ||
| func GetDefaultOperators() []string { |
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.
can't you directly assign instead of method.
| conditionTree, err := buildConditionTree(audience.Conditions) | ||
| if err != nil { | ||
| // @TODO: handle error | ||
| func() {}() // cheat the linters |
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.
Should we clean this up maybe, while we are touching the audiences.?
pkg/config/optimizely_config.go
Outdated
| // if audience condition is "NOT" then add "NOT" at start. | ||
| // Otherwise check if there is already audience id in serializedAudience | ||
| // then append condition between serializedAudience and item | ||
| if serializedAudience != "" || cond == "NOT" { |
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.
Should use a constant for the Operands here.
pkg/config/optimizely_config.go
Outdated
| func evaluateSubAudience(subAudience, serializedAudience, cond *string) { | ||
| // Checks if sub audience is empty or not | ||
| if *subAudience != "" { | ||
| if *serializedAudience != "" || *cond == "NOT" { |
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.
Same comment here for the operands, then we can reuse the constants.
| if experiment.AudienceConditions == nil { | ||
| return "" | ||
| } | ||
| return getSerializedAudiences(experiment.AudienceConditions, audiencesByID) |
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.
if getSerializedAudiences returns an empty string when experiment.AudienceConditions is nil then we dont need the first check here and can just use the getSerializedAudiences function.
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.
Overall LGTM just a few suggestions. Please see comments.
jaeopt
left a comment
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.
Overall looks great. Some changes suggested.
dustin-sier
left a comment
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 baring changes discussed
dustin-sier
left a comment
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.
This will approve it
jaeopt
left a comment
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 with nits
| tmpAttribute := entities.Attribute{ | ||
| ID: attribute.ID, | ||
| Key: attribute.Key, | ||
| } | ||
| _, ok := attributeMap[attribute.ID] | ||
| if !ok { | ||
| attributeMap[attribute.ID] = entities.Attribute{ | ||
| ID: attribute.ID, | ||
| Key: attribute.Key, | ||
| } | ||
| attributeMap[attribute.ID] = tmpAttribute |
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.
What's the point of this change?
| experimentGroupMap := map[string]string{"11111": "15"} | ||
|
|
||
| experiments, experimentKeyMap := MapExperiments(rawExperiments, experimentGroupMap) | ||
| experimentsId, experimentKeyMap := MapExperiments(rawExperiments, experimentGroupMap) |
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.
"experimentsId" name misleading. Shouldn't it be experimentMap or experimentIdMap?
| experimentGroupMap := map[string]string{"11111": "15"} | ||
|
|
||
| experiments, experimentKeyMap := MapExperiments(rawExperiments, experimentGroupMap) | ||
| experimentsIdMap, experimentKeyMap := MapExperiments(rawExperiments, experimentGroupMap) |
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.
experimentIdMap? to be consistent with experimentKeyMap
msohailhussain
left a comment
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
Summary
The following new public properties are added to OptimizelyConfig:
Test plan
All FSC tests OPTIMIZELY_CONFIG_V2 tests should pass.
FSC OptimizelyConfig link
Dependent PR
https://github.com/optimizely/fullstack-sdk-compatibility-suite/pull/526
Issues
Here's the simple snippet when you will run multiple times, it will give you different result. Maps are randomly picked.
https://stackoverflow.com/questions/55925822/why-are-iterations-over-maps-random