Repository: ietf-tools/datatracker

Issue:
When assignee rejects review secretary gets to see same review twice.
`type_defect`   |    by kivinen@iki.fi

___


I.e., when assigned reviewer rejects a review:

https://datatracker.ietf.org/doc/draft-ietf-core-yang-cbor/reviewrequest/14387/

And I as an secretary go to the 

https://datatracker.ietf.org/review/secdir/reviews/

page I can see the document twice on the "Unassigned review requests" section (see attached figure 1). 

Then when I try to do assignments and click "Manage unassigned reviews", I see the same document again twice (see attached figure 2). 

Now it is very easy to assign same document twice to different people, if I do not notice that the same document is in the list two times. 

If I close the review request that was rejected, both of the items disappear from the "Unassigned review requests". 

Now to get it back I need to go to the document again and request separate review for the document. I think I should have first assigned auto-suggested document to someone, and only after that close the previous review...

The datatracker should understand rejected assignments better, and combine the auto-suggestion and the rejected assignments to one assignment. I.e., most likely just show the rejected review request, and not create auto-suggested one for the same document if there is already rejected review to be assigned for the same document.

___
_Issue migrated from trac:3211 at 2022-03-04 08:12:26 +0000_
When assignee rejects review secretary gets to see same review twice.
`type_defect`   |    by kivinen@iki.fi

___


I.e., when assigned reviewer rejects a review:

https://datatracker.ietf.org/doc/draft-ietf-core-yang-cbor/reviewrequest/14387/

And I as an secretary go to the 

https://datatracker.ietf.org/review/secdir/reviews/

page I can see the document twice on the "Unassigned review requests" section (see attached figure 1). 

Then when I try to do assignments and click "Manage unassigned reviews", I see the same document again twice (see attached figure 2). 

Now it is very easy to assign same document twice to different people, if I do not notice that the same document is in the list two times. 

If I close the review request that was rejected, both of the items disappear from the "Unassigned review requests". 

Now to get it back I need to go to the document again and request separate review for the document. I think I should have first assigned auto-suggested document to someone, and only after that close the previous review...

The datatracker should understand rejected assignments better, and combine the auto-suggestion and the rejected assignments to one assignment. I.e., most likely just show the rejected review request, and not create auto-suggested one for the same document if there is already rejected review to be assigned for the same document.

___
_Issue migrated from trac:3211 at 2022-03-04 08:12:26 +0000_


Discussion:
_@kivinen@iki.fi_ _uploaded file [`Screenshot from 2021-03-04 17-43-35.png`](https://raw.githubusercontent.com/ietf-tools/svntrac-converted-attachments/main/datatracker/attachments/ticket/ad4/ad4c8d84fa26e440a290f58c8f4e4e8eccc8d7fa/361f47556ac988f7bcc7602003b14f19e6b4889a.png) (28.8 KiB)_

Figure 1
![Screenshot from 2021-03-04 17-43-35.png](https://raw.githubusercontent.com/ietf-tools/svntrac-converted-attachments/main/datatracker/attachments/ticket/ad4/ad4c8d84fa26e440a290f58c8f4e4e8eccc8d7fa/361f47556ac988f7bcc7602003b14f19e6b4889a.png)
_@kivinen@iki.fi_ _uploaded file [`Screenshot from 2021-03-04 17-44-02.png`](https://raw.githubusercontent.com/ietf-tools/svntrac-converted-attachments/main/datatracker/attachments/ticket/ad4/ad4c8d84fa26e440a290f58c8f4e4e8eccc8d7fa/489138a0cb527a87e25883bc22074f401e95d0a8.png) (119.7 KiB)_

Figure 2
![Screenshot from 2021-03-04 17-44-02.png](https://raw.githubusercontent.com/ietf-tools/svntrac-converted-attachments/main/datatracker/attachments/ticket/ad4/ad4c8d84fa26e440a290f58c8f4e4e8eccc8d7fa/489138a0cb527a87e25883bc22074f401e95d0a8.png)
_@rjsparks@nostrum.com_ _changed status from `new` to `accepted`_
The attachments for these issues were lost in trac before the transition to github, and cannot be recovered. If the issue is still relevant, and the attachments can be reconstructed, please add them as new comments.
@kivinen ☝️ (with apologies)
Good thing I do not clean up my temp directories too often so the old
images are still there...


-- 
***@***.***

![Screenshot from 2021-03-04 17-43-35](https://user-images.githubusercontent.com/10996692/158230905-46f54629-dd00-4407-b20e-a151f22a3aab.png)
---
![Screenshot from 2021-03-04 17-44-02](https://user-images.githubusercontent.com/10996692/158230908-69a8fe5e-e604-4cac-808b-c106081e4ce8.png)

I actually found out that this happens when the document is still considered to be auto assignment, i.e., it lists the review that was rejected, and then when finding out new documents that should be assigned it does not filter out those review requests that are already on the list. Also if you do the assignment of the rejected review request first, then you can close the another one without affecting the other one.
_@kivinen@iki.fi_ _uploaded file [`Screenshot from 2021-03-04 17-43-35.png`](https://raw.githubusercontent.com/ietf-tools/svntrac-converted-attachments/main/datatracker/attachments/ticket/ad4/ad4c8d84fa26e440a290f58c8f4e4e8eccc8d7fa/361f47556ac988f7bcc7602003b14f19e6b4889a.png) (28.8 KiB)_

Figure 1
![Screenshot from 2021-03-04 17-43-35.png](https://raw.githubusercontent.com/ietf-tools/svntrac-converted-attachments/main/datatracker/attachments/ticket/ad4/ad4c8d84fa26e440a290f58c8f4e4e8eccc8d7fa/361f47556ac988f7bcc7602003b14f19e6b4889a.png)
_@kivinen@iki.fi_ _uploaded file [`Screenshot from 2021-03-04 17-44-02.png`](https://raw.githubusercontent.com/ietf-tools/svntrac-converted-attachments/main/datatracker/attachments/ticket/ad4/ad4c8d84fa26e440a290f58c8f4e4e8eccc8d7fa/489138a0cb527a87e25883bc22074f401e95d0a8.png) (119.7 KiB)_

Figure 2
![Screenshot from 2021-03-04 17-44-02.png](https://raw.githubusercontent.com/ietf-tools/svntrac-converted-attachments/main/datatracker/attachments/ticket/ad4/ad4c8d84fa26e440a290f58c8f4e4e8eccc8d7fa/489138a0cb527a87e25883bc22074f401e95d0a8.png)
_@rjsparks@nostrum.com_ _changed status from `new` to `accepted`_
The attachments for these issues were lost in trac before the transition to github, and cannot be recovered. If the issue is still relevant, and the attachments can be reconstructed, please add them as new comments.
@kivinen ☝️ (with apologies)
Good thing I do not clean up my temp directories too often so the old
images are still there...


-- 
***@***.***

![Screenshot from 2021-03-04 17-43-35](https://user-images.githubusercontent.com/10996692/158230905-46f54629-dd00-4407-b20e-a151f22a3aab.png)
---
![Screenshot from 2021-03-04 17-44-02](https://user-images.githubusercontent.com/10996692/158230908-69a8fe5e-e604-4cac-808b-c106081e4ce8.png)

I actually found out that this happens when the document is still considered to be auto assignment, i.e., it lists the review that was rejected, and then when finding out new documents that should be assigned it does not filter out those review requests that are already on the list. Also if you do the assignment of the rejected review request first, then you can close the another one without affecting the other one.

Resolving patch:
diff --git a/ietf/review/utils.py b/ietf/review/utils.py
--- a/ietf/review/utils.py
+++ b/ietf/review/utils.py
@@ -589,10 +589,12 @@ def blocks(existing, request):
                    and existing.reviewassignment_set.filter(state_id__in=("assigned", "accepted")).exists()
                    and (not existing.requested_rev or existing.requested_rev == request.doc.rev))
         request_closed = existing.state_id not in ('requested','assigned')
+        # Is there a review request for this document already in system
+        requested = existing.state_id in ('requested') and (not existing.requested_rev or existing.requested_rev == request.doc.rev)
         # at least one assignment was completed for the requested version or the current doc version if no specific version was requested:
         some_assignment_completed = existing.reviewassignment_set.filter(reviewed_rev=existing.requested_rev or existing.doc.rev, state_id='completed').exists()
 
-        return any([no_review_document, no_review_rev, pending, request_closed, some_assignment_completed])
+        return any([no_review_document, no_review_rev, pending, request_closed, requested, some_assignment_completed])
 
     res = [r for r in requests.values()
            if not any(blocks(e, r) for e in existing_requests[r.doc_id])]


Test patch:
diff --git a/ietf/group/tests_review.py b/ietf/group/tests_review.py
--- a/ietf/group/tests_review.py
+++ b/ietf/group/tests_review.py
@@ -101,8 +101,20 @@ def test_suggested_review_requests(self):
 
         self.assertEqual(list(suggested_review_requests_for_team(team)), [])
 
+        # blocked by an already existing request (don't suggest it again)
+        review_req.state_id = "requested"
+        review_req.save()
+        self.assertEqual(list(suggested_review_requests_for_team(team)), [])
+
+        # ... but not for a previous version
+        review_req.requested_rev = prev_rev
+        review_req.save()
+        self.assertEqual(len(suggested_review_requests_for_team(team)), 1)
+
+
         # blocked by completion
         review_req.state = ReviewRequestStateName.objects.get(slug="assigned")
+        review_req.requested_rev = ""
         review_req.save()
         assignment.state = ReviewAssignmentStateName.objects.get(slug="completed")
         assignment.reviewed_rev = review_req.doc.rev
@@ -116,6 +128,7 @@ def test_suggested_review_requests(self):
 
         self.assertEqual(len(suggested_review_requests_for_team(team)), 1)
 
+
     def test_suggested_review_requests_on_lc_and_telechat(self):
         review_req = ReviewRequestFactory(state_id='assigned')
         doc = review_req.doc