Repository: ietf-tools/datatracker

Issue:
History of reviewer settings does not seem to list everything
`type_defect`   |    by kivinen@iki.fi

___


When I look the history of someone for example my own 

https://datatracker.ietf.org/review/secdir/reviewers/kivinen@iki.fi/settings/

there is entries like:

2021-03-04 	Tero Kivinen 	None
2021-03-04 	Tero Kivinen 	Updated request_assignment_next
2021-03-04 	Tero Kivinen 	Updated filter_re, request_assignment_next
2021-03-04 	Tero Kivinen 	Updated min_interval, filter_re
2021-03-04 	Tero Kivinen 	Updated min_interval
2021-03-04 	Tero Kivinen 	skipped

Which tells which fields have been changed, but it does not tell what was the old value of the field, and what is new value of the field. 

It should say 

2021-03-04 	Tero Kivinen 	Updated min_interval from "" to "once per week"
2021-03-04 	Tero Kivinen 	skipped field changed from 0 to 1

etc. Also if seems to make entry 

2021-03-04 	Tero Kivinen 	None

every time I save the page, i.e., when I save and have not done any changes. There is no point of having these kind of log entries there. If I have not done any changes and press save, it should just detect that, and not create log entry (i.e., do similarly than what happens when you press "cancel").

___
_Issue migrated from trac:3213 at 2022-03-04 08:12:37 +0000_
History of reviewer settings does not seem to list everything
`type_defect`   |    by kivinen@iki.fi

___


When I look the history of someone for example my own 

https://datatracker.ietf.org/review/secdir/reviewers/kivinen@iki.fi/settings/

there is entries like:

2021-03-04 	Tero Kivinen 	None
2021-03-04 	Tero Kivinen 	Updated request_assignment_next
2021-03-04 	Tero Kivinen 	Updated filter_re, request_assignment_next
2021-03-04 	Tero Kivinen 	Updated min_interval, filter_re
2021-03-04 	Tero Kivinen 	Updated min_interval
2021-03-04 	Tero Kivinen 	skipped

Which tells which fields have been changed, but it does not tell what was the old value of the field, and what is new value of the field. 

It should say 

2021-03-04 	Tero Kivinen 	Updated min_interval from "" to "once per week"
2021-03-04 	Tero Kivinen 	skipped field changed from 0 to 1

etc. Also if seems to make entry 

2021-03-04 	Tero Kivinen 	None

every time I save the page, i.e., when I save and have not done any changes. There is no point of having these kind of log entries there. If I have not done any changes and press save, it should just detect that, and not create log entry (i.e., do similarly than what happens when you press "cancel").

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


Discussion:
_@rjsparks@nostrum.com_ _changed status from `new` to `accepted`_
_@kivinen@iki.fi_ _changed priority from `medium` to `major`_
_@kivinen@iki.fi_ _commented_


___
I was trying to see why some person has "indicated he wanted to be first in queue" and I think it is because he rejected a review earlier, but that when I tried to check the history of settings or something I noticed that the history of settings is completely unusable. 

There are only "skipped" and "none" entries there, and there seems to be skipped entry for EVERY single case I have NOT assigned something to him or so, as there is 4 skips for 2021-10-28, and 1 skip for 2021-10-23, and 5 for 2021-10-18 etc.

I.e., the history is compeltely unusable, and does not really offer any useful information. 

We do need to get some usable history of settings and what reviews have been assigned to who at what point and what happened to them somewhere. 

Not being able to see history from the datatracker, thus being required to go back to emails sent to secretary is really affecting how I can do work, thus raising the priority from medium to majer...
Per discussion with Tero, things like:
<img width="793" alt="image" src="https://user-images.githubusercontent.com/10996692/227704721-d36628b5-8c2a-4486-b9f9-c42356b3ec70.png">
is not useful

And I just confirmed that the few having description of "None" means I actually did assign that person a document on that day.
_@rjsparks@nostrum.com_ _changed status from `new` to `accepted`_
_@kivinen@iki.fi_ _changed priority from `medium` to `major`_
_@kivinen@iki.fi_ _commented_


___
I was trying to see why some person has "indicated he wanted to be first in queue" and I think it is because he rejected a review earlier, but that when I tried to check the history of settings or something I noticed that the history of settings is completely unusable. 

There are only "skipped" and "none" entries there, and there seems to be skipped entry for EVERY single case I have NOT assigned something to him or so, as there is 4 skips for 2021-10-28, and 1 skip for 2021-10-23, and 5 for 2021-10-18 etc.

I.e., the history is compeltely unusable, and does not really offer any useful information. 

We do need to get some usable history of settings and what reviews have been assigned to who at what point and what happened to them somewhere. 

Not being able to see history from the datatracker, thus being required to go back to emails sent to secretary is really affecting how I can do work, thus raising the priority from medium to majer...
Per discussion with Tero, things like:
<img width="793" alt="image" src="https://user-images.githubusercontent.com/10996692/227704721-d36628b5-8c2a-4486-b9f9-c42356b3ec70.png">
is not useful

And I just confirmed that the few having description of "None" means I actually did assign that person a document on that day.

Resolving patch:
diff --git a/ietf/doc/templatetags/ietf_filters.py b/ietf/doc/templatetags/ietf_filters.py
--- a/ietf/doc/templatetags/ietf_filters.py
+++ b/ietf/doc/templatetags/ietf_filters.py
@@ -881,3 +881,21 @@ def badgeify(blob):
             )
 
     return text
+
+@register.filter
+def simple_history_delta_changes(history):
+    """Returns diff between given history and previous entry."""
+    prev = history.prev_record
+    if prev:
+        delta = history.diff_against(prev)
+        return delta.changes
+    return []
+
+@register.filter
+def simple_history_delta_change_cnt(history):
+    """Returns number of changes between given history and previous entry."""
+    prev = history.prev_record
+    if prev:
+        delta = history.diff_against(prev)
+        return len(delta.changes)
+    return 0
diff --git a/ietf/review/policies.py b/ietf/review/policies.py
--- a/ietf/review/policies.py
+++ b/ietf/review/policies.py
@@ -131,12 +131,15 @@ def _update_skip_next(self, rotation_pks, assignee_person):
         assignee_index = rotation_pks.index(assignee_person.pk)
         skipped = rotation_pks[0:assignee_index]
         skipped_settings = self.team.reviewersettings_set.filter(person__in=skipped)  # list of PKs is valid here
+        changed = []
         for ss in skipped_settings:
-            ss.skip_next = max(0, ss.skip_next - 1)  # ensure we don't go negative
-        bulk_update_with_history(skipped_settings,
+            if ss.skip_next > 0:
+                ss.skip_next = max(0, ss.skip_next - 1)  # ensure we don't go negative
+                ss._change_reason = "Skip count decremented"
+                changed.append(ss)
+        bulk_update_with_history(changed,
                                  ReviewerSettings,
-                                 ['skip_next'],
-                                 default_change_reason='skipped')
+                                 ['skip_next'])
 
     def _assignment_in_order(self, rotation_pks, assignee_person):
         """Is this an in-order assignment?"""
@@ -262,12 +265,15 @@ def _filter_unavailable_reviewers(self, reviewers, review_req=None):
 
     def _clear_request_next_assignment(self, person):
         s = self._reviewer_settings_for(person)
-        s.request_assignment_next = False
-        s.save()
+        if s.request_assignment_next:
+            s.request_assignment_next = False
+            s._change_reason = "Clearing request next assignment"
+            s.save()
 
     def _add_skip(self, person):
         s = self._reviewer_settings_for(person)
         s.skip_next += 1
+        s._change_reason = "Incrementing skip count"
         s.save()
 
     def _reviewer_settings_for(self, person):
@@ -484,6 +490,7 @@ def set_wants_to_be_next(self, reviewer_person):
         # Instead, the "assign me next" flag is set.
         settings = self._reviewer_settings_for(reviewer_person)
         settings.request_assignment_next = True
+        settings._change_reason = "Setting request next assignment"
         settings.save()
 
     def _update_skip_next(self, rotation_pks, assignee_person):
@@ -523,20 +530,22 @@ def _update_skip_next(self, rotation_pks, assignee_person):
             min_skip_next = min([rs.skip_next for rs in rotation_settings.values()])
 
         next_reviewer_index = None
+        changed = []
         for index, pk in enumerate(unfolded_rotation_pks):
             rs = rotation_settings.get(pk)
             if (rs is None) or (rs.skip_next == min_skip_next):
                 next_reviewer_index = index
                 break
             else:
-                rs.skip_next = max(0, rs.skip_next - 1)  # ensure never negative
+                if rs.skip_next > 0:
+                    rs.skip_next = max(0, rs.skip_next - 1)  # ensure never negative
+                    rs._change_reason = "Skip count decremented"
+                    changed.append(rs)
                 
         log.assertion('next_reviewer_index is not None')  # some entry in the list must have the minimum value
-
-        bulk_update_with_history(rotation_settings.values(),
+        bulk_update_with_history(changed,
                                  ReviewerSettings,
-                                 ['skip_next'],
-                                 default_change_reason='skipped')
+                                 ['skip_next'])
 
         next_reviewer_pk = unfolded_rotation_pks[next_reviewer_index]
         NextReviewerInTeam.objects.update_or_create(
@@ -578,6 +587,7 @@ def set_wants_to_be_next(self, reviewer_person):
         # who rejected a review and no further action is needed.
         settings = self._reviewer_settings_for(reviewer_person)
         settings.request_assignment_next = True
+        settings._change_reason = "Setting request next assignment"
         settings.save()
 
 


Test patch: