Skip to content

Commit

Permalink
fixes #9201 bug(nimbus): Do not use negation in targeting expressions (
Browse files Browse the repository at this point in the history
…#9204)

Because:
- the JEXL evaluator in mobile does not support negation (`!expr`)

this commit:
- updates the generated exclusion targeting not to use negation and use
comparison instead.
  • Loading branch information
Barret Rennie authored Aug 2, 2023
1 parent 8669383 commit fdfe778
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion experimenter/experimenter/experiments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,9 @@ def targeting(self):
if excluded_experiments := self.excluded_experiments.order_by("id").values_list(
"slug", flat=True
):
# Mobile does not support ! in expressions.
sticky_expressions.extend(
f"!('{slug}' in enrollments)" for slug in excluded_experiments
f"('{slug}' in enrollments) == false" for slug in excluded_experiments
)
if required_experiments := self.required_experiments.order_by("id").values_list(
"slug", flat=True
Expand Down
4 changes: 2 additions & 2 deletions experimenter/experimenter/experiments/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,12 +794,12 @@ def test_targeting_without_prevent_pref_conflicts_sets_prefs(self):
[
([], [], "true"),
(["foo"], [], "('foo' in enrollments)"),
([], ["bar"], "(!('bar' in enrollments))"),
([], ["bar"], "(('bar' in enrollments) == false)"),
(
["foo", "bar"],
["baz"],
(
"(!('baz' in enrollments)) && "
"(('baz' in enrollments) == false) && "
"('foo' in enrollments) && "
"('bar' in enrollments)"
),
Expand Down

0 comments on commit fdfe778

Please sign in to comment.