Skip to content

Commit

Permalink
Check for target conditions due to the exact matching case
Browse files Browse the repository at this point in the history
  • Loading branch information
zachaysan committed Jan 31, 2025
1 parent fc8b581 commit 9ba8ca3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/segments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ def assign_conditions_if_matching_rule( # noqa: C901
return True

matched_conditions = set()
matched_target_conditions = set()

# In order to provide accurate diffs we first go through the conditions
# and collect conditions that are exact matches (i.e. have not been modified)
Expand All @@ -398,17 +399,21 @@ def assign_conditions_if_matching_rule( # noqa: C901
target_condition
):
matched_conditions.add(condition)
matched_target_conditions.add(target_condition)
condition.version_of = target_condition
break

# Next we go through the collection again and collect conditions that have
# been modified from the target condition.
for target_condition in target_conditions:
for condition in conditions:
if (condition not in matched_conditions) and condition.is_partial_match(
target_condition
if (
(condition not in matched_conditions)
and (target_condition not in matched_target_conditions)
and condition.is_partial_match(target_condition)
):
matched_conditions.add(condition)
matched_target_conditions.add(target_condition)
condition.version_of = target_condition
break

Expand Down

0 comments on commit 9ba8ca3

Please sign in to comment.