-
Notifications
You must be signed in to change notification settings - Fork 829
feat: Give AD the action in ad-f-up doc state #6272
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0add3bb
refactor: Add helper class to compare tag changes
jennifer-richards f1a5fa2
feat: Give AD the action in ad-f-up state
jennifer-richards 1ee3f73
refactor: Remove unnecessary check
jennifer-richards bed9c3f
refactor: Reorganize update_action_holders()
jennifer-richards 1013740
refactor: Remove unnecessary guard
jennifer-richards 60078cb
test: Update test for new AD handling
jennifer-richards 61e1adc
test: Update another test
jennifer-richards 1298351
Merge branch 'main' into ad-actionholder
jennifer-richards c64e2b8
test: Test ad-f-up effect on action holders
jennifer-richards 7f06819
Merge branch 'main' into ad-actionholder
rjsparks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| import textwrap | ||
|
|
||
| from collections import defaultdict, namedtuple, Counter | ||
| from dataclasses import dataclass | ||
| from typing import Union | ||
| from zoneinfo import ZoneInfo | ||
|
|
||
|
|
@@ -460,6 +461,21 @@ def add_action_holder_change_event(doc, by, prev_set, reason=None): | |
| ) | ||
|
|
||
|
|
||
| @dataclass | ||
| class TagSetComparer: | ||
| before: set[str] | ||
| after: set[str] | ||
|
|
||
| def changed(self): | ||
| return self.before != self.after | ||
|
|
||
| def added(self, tag): | ||
| return tag in self.after and tag not in self.before | ||
|
|
||
| def removed(self, tag): | ||
| return tag in self.before and tag not in self.after | ||
|
|
||
|
|
||
| def update_action_holders(doc, prev_state=None, new_state=None, prev_tags=None, new_tags=None): | ||
| """Update the action holders for doc based on state transition | ||
|
|
||
|
|
@@ -473,34 +489,45 @@ def update_action_holders(doc, prev_state=None, new_state=None, prev_tags=None, | |
| if prev_state and new_state: | ||
| assert prev_state.type_id == new_state.type_id | ||
|
|
||
| # Convert tags to sets of slugs | ||
| prev_tag_slugs = {t.slug for t in (prev_tags or [])} | ||
| new_tag_slugs = {t.slug for t in (new_tags or [])} | ||
| # Convert tags to sets of slugs | ||
| tags = TagSetComparer( | ||
| before={t.slug for t in (prev_tags or [])}, | ||
| after={t.slug for t in (new_tags or [])}, | ||
| ) | ||
|
|
||
| # Do nothing if state / tag have not changed | ||
| if (prev_state == new_state) and (prev_tag_slugs == new_tag_slugs): | ||
| if (prev_state == new_state) and not tags.changed(): | ||
| return None | ||
|
|
||
| # Remember original list of action holders to later check if it changed | ||
| prev_set = list(doc.action_holders.all()) | ||
| # Only draft-iesg states are of interest (for now) | ||
| if (prev_state != new_state) and (getattr(new_state, 'type_id') == 'draft-iesg'): | ||
|
|
||
| # Update the action holders. To get this right for people with more | ||
| # than one relationship to the document, do removals first, then adds. | ||
| # Remove outdated action holders | ||
| iesg_state_changed = (prev_state != new_state) and (getattr(new_state, "type_id", None) == "draft-iesg") | ||
| if iesg_state_changed: | ||
| # Clear the action_holders list on a state change. This will reset the age of any that get added back. | ||
| doc.action_holders.clear() | ||
| if doc.ad and new_state.slug not in DocumentActionHolder.CLEAR_ACTION_HOLDERS_STATES: | ||
| # Default to responsible AD for states other than these | ||
| if tags.removed("need-rev"): | ||
| # Removed the 'need-rev' tag - drop authors from the action holders list | ||
| DocumentActionHolder.objects.filter(document=doc, person__in=doc.authors()).delete() | ||
| elif tags.added("need-rev"): | ||
| # Remove the AD if we're asking for a new revision | ||
| DocumentActionHolder.objects.filter(document=doc, person=doc.ad).delete() | ||
|
|
||
| # Add new action holders | ||
| if doc.ad: | ||
| # AD is an action holder unless specified otherwise for the new state | ||
| if iesg_state_changed and new_state.slug not in DocumentActionHolder.CLEAR_ACTION_HOLDERS_STATES: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this needs a test around it proving that #6266 has been addressed?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, thanks for catching that. I've added a test. |
||
| doc.action_holders.add(doc.ad) | ||
|
|
||
| if prev_tag_slugs != new_tag_slugs: | ||
| # If we have added or removed the need-rev tag, add or remove authors as action holders | ||
| if ('need-rev' in prev_tag_slugs) and ('need-rev' not in new_tag_slugs): | ||
| # Removed the 'need-rev' tag - drop authors from the action holders list | ||
| DocumentActionHolder.objects.filter(document=doc, person__in=doc.authors()).delete() | ||
| elif ('need-rev' not in prev_tag_slugs) and ('need-rev' in new_tag_slugs): | ||
| # Added the 'need-rev' tag - add authors to the action holders list | ||
| for auth in doc.authors(): | ||
| if not doc.action_holders.filter(pk=auth.pk).exists(): | ||
| doc.action_holders.add(auth) | ||
| # If AD follow-up is needed, make sure they are an action holder | ||
| if tags.added("ad-f-up"): | ||
| doc.action_holders.add(doc.ad) | ||
| # Authors get the action if a revision is needed | ||
| if tags.added("need-rev"): | ||
| for auth in doc.authors(): | ||
| doc.action_holders.add(auth) | ||
|
|
||
| # Now create an event if we changed the set | ||
| return add_action_holder_change_event( | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Only a few seconds thought given to it, but I'm not seeing a case where this tag being added shouldn't relieve the AD of being an action holder. (In case that's too many nested nots, I think the ad should be removed as an action holder when this tag is added.
@larseggert - am I missing any use cases that say the AD should remain as an action holder when this tag is added?
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.
Sounds reasonable to me - I'll add
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.
When which tag is added?
Uh oh!
There was an error while loading. Please reload this page.
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.
the "need-rev" (identified as the "Revised I-D needed" in the UI) tag
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.
When that is added, IMO the AD should never remain an action holder.