-
Notifications
You must be signed in to change notification settings - Fork 28
fix: Forced variation not available in experiment #292
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
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
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.
A fix suggested. Also need a unit test covering the case.
lib/optimizely.rb
Outdated
variation_id = if !variation | ||
experiment_id != '' ? config.get_variation_id_from_key_by_experiment_id(experiment_id, variation_key) : '' | ||
else | ||
variation ? variation['id'] : '' | ||
end |
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.
variation_id = if !variation | |
experiment_id != '' ? config.get_variation_id_from_key_by_experiment_id(experiment_id, variation_key) : '' | |
else | |
variation ? variation['id'] : '' | |
end | |
variation_id = variation ? variation['id'] : '' |
If it's null from get_flag_variagtion(), then get_variation_id_from_key_by_experiment_id() will also return null.
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 is independent of flag_key
, for a/b
experiments this will return non-null and get_flag_variation
will return null.
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.
@msohailhussain A good point! I still see this code can be refactored. Can consider the same comment for this:
https://github.com/optimizely/php-sdk/pull/237/files#r770133288
@@ -298,8 +298,8 @@ def decide_for_keys(user_context, keys, decide_options = []) | |||
decisions | |||
end | |||
|
|||
8000 | def get_flag_variation_by_key(flag_key, variation_key) | ||
project_config.get_variation_from_flag(flag_key, variation_key) | |||
def get_flag_variation(flag_key, target_value, attribute) |
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.
please add description of this method.
There was a problem hiding this comment.
Choose a reason fo 8000 r hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unit test looks good! A suggestion for refactoring.
lib/optimizely.rb
Outdated
variation_id = if !variation | ||
experiment_id != '' ? config.get_variation_id_from_key_by_experiment_id(experiment_id, variation_key) : '' | ||
else | ||
variation ? variation['id'] : '' | ||
end |
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.
@msohailhussain A good point! I still see this code can be refactored. Can consider the same comment for this:
https://github.com/optimizely/php-sdk/pull/237/files#r770133288
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
Test plan