Skip to content

Commit 9170378

Browse files
authored
Merge pull request #496 from ChillarAnand/dash
Update sorting logic
2 parents 6c4186f + f60cfe8 commit 9170378

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

junction/proposals/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def get_reviewer_votes_count(self):
178178
def get_reviewer_votes_count_by_value(self, vote_value):
179179
""" Show sum of reviewer votes for given vote value. """
180180
return ProposalSectionReviewerVote.objects.filter(
181-
proposal=self, vote_value=vote_value
181+
proposal=self, vote_value__vote_value=vote_value
182182
).count()
183183

184184
def get_reviewer_votes_sum(self):

junction/proposals/utils.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,34 +50,28 @@ def _sort_proposals_for_dashboard(conference, proposals_qs, user, form):
5050
proposals_qs = [p for p in proposals_qs if not p.has_negative_votes()]
5151
proposals_qs = sorted(proposals_qs, key=lambda x: x.get_reviewer_votes_sum(), reverse=True)
5252

53-
selected = [p for p in proposals_qs if p.get_reviewer_votes_count_by_value(ProposalReviewVote.MUST_HAVE) > 1]
53+
selected = [p for p in proposals_qs if p.get_reviewer_votes_count_by_value(ProposalReviewVote.MUST_HAVE) >= 2]
5454
proposals.append(s_items('Selected', selected))
5555

56-
batches = []
57-
5856
batch1 = [p for p in proposals_qs
59-
if p.get_reviewer_votes_count_by_value(ProposalReviewVote.MUST_HAVE) > 0 and
60-
p.get_reviewer_votes_count_by_value(ProposalReviewVote.GOOD) > 1]
57+
if p.get_reviewer_votes_count_by_value(ProposalReviewVote.MUST_HAVE) == 1 and
58+
p.get_reviewer_votes_count_by_value(ProposalReviewVote.GOOD) > 2]
6159
proposals.append(s_items('1 Must Have & 2+ Good Votes', batch1))
62-
batches += batch1
6360

6461
batch2 = [p for p in proposals_qs
65-
if p.get_reviewer_votes_count_by_value(ProposalReviewVote.MUST_HAVE) > 0 and
66-
p.get_reviewer_votes_count_by_value(ProposalReviewVote.GOOD) > 0 and
67-
p not in batches]
62+
if p.get_reviewer_votes_count_by_value(ProposalReviewVote.MUST_HAVE) == 1 and
63+
p.get_reviewer_votes_count_by_value(ProposalReviewVote.GOOD) == 1]
6864
proposals.append(s_items('1 Must Have & 1 Good Vote', batch2))
69-
batches += batch2
7065

7166
batch3 = [p for p in proposals_qs
72-
if p.get_reviewer_votes_count_by_value(ProposalReviewVote.GOOD) > 1 and
73-
p not in batches]
67+
if p.get_reviewer_votes_count_by_value(ProposalReviewVote.GOOD) > 2 and
68+
p not in batch1]
7469
proposals.append(s_items('2+ Good Votes', batch3))
75-
batches += batch3
7670

7771
batch4 = [p for p in proposals_qs
78-
if p.get_reviewer_votes_count_by_value(ProposalReviewVote.GOOD) > 0 and
79-
p.get_reviewer_votes_count_by_value(ProposalReviewVote.NOT_BAD) > 1 and
80-
p not in batches]
72+
if p.get_reviewer_votes_count_by_value(ProposalReviewVote.GOOD) == 1 and
73+
p.get_reviewer_votes_count_by_value(ProposalReviewVote.NOT_BAD) > 2 and
74+
p not in batch2]
8175
proposals.append(s_items('1 Good & 2+ Not Bad votes', batch4))
8276

8377
if votes not in (ProposalVotesFilter.SORT_BY_SUM, ProposalVotesFilter.SORT_BY_SELECTION):

0 commit comments

Comments
 (0)