Skip to content

Commit

Permalink
fix: prevent dups in DraftAliasGenerator (#7650)
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-richards committed Jul 10, 2024
1 parent 20f183c commit b2a858c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ietf/doc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1389,15 +1389,17 @@ def __iter__(self) -> Iterator[tuple[str, list[str]]]:
# states__type_id, states__slug directly in the `filter()`
# works, but it does not work as expected in `exclude()`.
active_state = State.objects.get(type_id="draft", slug="active")
active_pks = [] # build a static list of the drafts we actually returned as "active"
active_drafts = drafts.filter(states=active_state)
for this_draft in active_drafts:
active_pks.append(this_draft.pk)
for alias, addresses in self._yield_aliases_for_draft(this_draft):
yield alias, addresses

# Annotate with the draft state slug so we can check for drafts that
# have become RFCs
inactive_recent_drafts = (
drafts.exclude(states=active_state)
drafts.exclude(pk__in=active_pks) # don't re-filter by state, states may have changed during the run!
.filter(expires__gte=show_since)
.annotate(
# Why _default_manager instead of objects? See:
Expand Down

0 comments on commit b2a858c

Please sign in to comment.