From 72467331546de3e9d3fd30cae5003883d5921ccc Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Tue, 23 Aug 2016 10:06:48 +0000 Subject: [PATCH] Reword assignment choices code to make it a bit clearer - Legacy-Id: 11838 --- ietf/review/utils.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ietf/review/utils.py b/ietf/review/utils.py index cfdc43fa7..443c19cbc 100644 --- a/ietf/review/utils.py +++ b/ietf/review/utils.py @@ -333,10 +333,10 @@ def make_assignment_choices(email_queryset, review_req): now = datetime.datetime.now() - def add_boolean_score(scores, direction, expr, expl): + def add_boolean_score(scores, direction, expr, explanation): scores.append(int(bool(expr)) * direction) if expr: - explanations.append(expl) + explanations.append(explanation) ranking = [] for e in possible_emails: @@ -344,9 +344,6 @@ def make_assignment_choices(email_queryset, review_req): if not reviewer: reviewer = ReviewerSettings() - explanations = [] - scores = [] # build up score in separate independent components - days_past = None latest = latest_assignment_for_reviewer.get(e.pk) if latest is not None: @@ -362,11 +359,17 @@ def make_assignment_choices(email_queryset, review_req): d = -d ready_for = "frequency exceeded, ready in {} {}".format(d, "day" if d == 1 else "days") - explanations.append(ready_for) + + # we sort the reviewers by separate axes, listing the most + # important things first + scores = [] + explanations = [] + + explanations.append(ready_for) # show ready for explanation first, but sort it after the other issues add_boolean_score(scores, +1, e.pk in has_reviewed_previous, "reviewed document before") add_boolean_score(scores, +1, e.pk in would_like_to_review, "wants to review document") - add_boolean_score(scores, -1, e.pk in connections, connections.get(e.pk)) + add_boolean_score(scores, -1, e.pk in connections, connections.get(e.pk)) # reviewer is somehow connected: bad add_boolean_score(scores, -1, reviewer.filter_re and any(re.search(reviewer.filter_re, n) for n in aliases), "filter regexp matches") add_boolean_score(scores, -1, reviewer.unavailable_until and reviewer.unavailable_until > now, "unavailable until {}".format((reviewer.unavailable_until or now).strftime("%Y-%m-%d %H:%M:%S")))