-
Notifications
You must be signed in to change notification settings - Fork 35
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
feat (audiences): Audience combinations #150
Conversation
… oakbani/audience-match-types-project-config
… oakbani/audience-match-types-project-config
…ience-match-type-condition-evaluator-2
… oakbani/audience-match-types-project-config
… oakbani/audience-match-types-project-config
… oakbani/audience-match-types-project-config
Co-Authored-By: oakbani <owais.akbani92@gmail.com>
… oakbani/audience-match-types-project-config
optimizely/helpers/audience.py
Outdated
@@ -50,17 +29,34 @@ def is_user_in_experiment(config, experiment, attributes): | |||
""" | |||
|
|||
# Return True in case there are no audiences | |||
if not experiment.audienceIds: | |||
audience_conditions = experiment.getAudienceConditionsOrIds() | |||
if not audience_conditions: |
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.
Nit: it'd be safer to perform an explicit check
if audience_conditions is None or audience_conditions == []:
especially since the condition tree may be a single leaf node (an audience ID) and that leaf node could (theoretically) be (''
).
optimizely/helpers/audience.py
Outdated
|
||
eval_result = condition_tree_evaluator.evaluate( | ||
audience_conditions, | ||
lambda audienceId: evaluate_audience(audienceId) |
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.
lambda audienceId: evaluate_audience(audienceId) | |
evaluate_audience |
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.
Thanks for updating! I haven't looked very closely at the unit tests; will rely on the compatibility suite to catch any issues with correctness.
tests/helpers_tests/test_audience.py
Outdated
|
||
self.assertStrictFalse(audience.is_user_in_experiment(self.project_config, experiment, user_attributes)) | ||
|
||
def test_is_user_in_experiment__evaluates_audience_Ids(self): |
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.
Nit: maybe delete the underscore in audience_Ids
?
…ience-combinations-2
Summary
This adds support for audience combinations on experiments. If
experiment.audienceConditions
is present, it will be used as a condition tree where the leaf conditions are audience Ids.Test plan
Issues