Skip to content

Commit

Permalink
ref: avoid filtering on id=None
Browse files Browse the repository at this point in the history
this technically works at runtime, but django-stubs (imo correctly) flags this as a mistake
  • Loading branch information
asottile-sentry committed Jul 29, 2024
1 parent 8ace131 commit c0bbcf4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/sentry/api/endpoints/project_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,12 @@ def find_duplicate(self) -> Rule | None:
"""
Determines whether specified rule already exists, and if it does, returns it.
"""
existing_rules = Rule.objects.exclude(id=self._rule_id).filter(
project__id=self._project_id, status=ObjectStatus.ACTIVE
)
if self._rule_id is None:
all_rules = Rule.objects.all()
else:
all_rules = Rule.objects.exclude(id=self._rule_id)

existing_rules = all_rules.filter(project__id=self._project_id, status=ObjectStatus.ACTIVE)
for existing_rule in existing_rules:
keys_checked = 0
keys_matched = 0
Expand Down

0 comments on commit c0bbcf4

Please sign in to comment.