Skip to content

Commit 7246733

Browse files
committed
Reword assignment choices code to make it a bit clearer
- Legacy-Id: 11838
1 parent 742bf4b commit 7246733

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

ietf/review/utils.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,20 +333,17 @@ def make_assignment_choices(email_queryset, review_req):
333333

334334
now = datetime.datetime.now()
335335

336-
def add_boolean_score(scores, direction, expr, expl):
336+
def add_boolean_score(scores, direction, expr, explanation):
337337
scores.append(int(bool(expr)) * direction)
338338
if expr:
339-
explanations.append(expl)
339+
explanations.append(explanation)
340340

341341
ranking = []
342342
for e in possible_emails:
343343
reviewer = reviewers.get(e.person_id)
344344
if not reviewer:
345345
reviewer = ReviewerSettings()
346346

347-
explanations = []
348-
scores = [] # build up score in separate independent components
349-
350347
days_past = None
351348
latest = latest_assignment_for_reviewer.get(e.pk)
352349
if latest is not None:
@@ -362,11 +359,17 @@ def add_boolean_score(scores, direction, expr, expl):
362359
d = -d
363360
ready_for = "frequency exceeded, ready in {} {}".format(d, "day" if d == 1 else "days")
364361

365-
explanations.append(ready_for)
362+
363+
# we sort the reviewers by separate axes, listing the most
364+
# important things first
365+
scores = []
366+
explanations = []
367+
368+
explanations.append(ready_for) # show ready for explanation first, but sort it after the other issues
366369

367370
add_boolean_score(scores, +1, e.pk in has_reviewed_previous, "reviewed document before")
368371
add_boolean_score(scores, +1, e.pk in would_like_to_review, "wants to review document")
369-
add_boolean_score(scores, -1, e.pk in connections, connections.get(e.pk))
372+
add_boolean_score(scores, -1, e.pk in connections, connections.get(e.pk)) # reviewer is somehow connected: bad
370373
add_boolean_score(scores, -1, reviewer.filter_re and any(re.search(reviewer.filter_re, n) for n in aliases), "filter regexp matches")
371374
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")))
372375

0 commit comments

Comments
 (0)