Fixes some errors with reviewer averages

This commit is contained in:
Christopher Neugebauer 2016-08-15 15:35:25 +10:00
parent 9c2087c778
commit cc6db4ed88

View file

@ -257,13 +257,16 @@ def review_admin(request, section_slug):
continue
already_seen.add(user.pk)
user.comment_count = Review.objects.filter(user=user).count()
user.comment_count = Review.objects.filter(
user=user,
proposal__kind__section__slug=section_slug,
).count()
user_votes = LatestVote.objects.filter(
user=user,
proposal__kind__section__slug=section_slug,
)
print section_slug
print [vote.proposal.kind.section.slug for vote in user_votes]
user.total_votes = user_votes.exclude(
vote=LatestVote.VOTES.ABSTAIN,
).count()
@ -282,19 +285,23 @@ def review_admin(request, section_slug):
user.abstain = user_votes.filter(
vote=LatestVote.VOTES.ABSTAIN,
).count()
if user.total_votes == 0:
user.average = "-"
else:
user.average = (
user.plus_two + user.plus_one +
user.minus_one + user.minus_two
((user.plus_two * 2) + user.plus_one) -
((user.minus_two * 2) + user.minus_one)
) / (user.total_votes * 1.0)
yield user
reviewers_sorted = list(reviewers())
sort(reviewers_sorted: key= lambda reviewer: 0 - reviewer.total_votes)
ctx = {
"section_slug": section_slug,
"reviewers": reviewers(),
"reviewers": reviewers_sorted,
}
return render(request, "symposion/reviews/review_admin.html", ctx)