Commit ad651bbac7c2584e3a0c4ca978dc19b6dfeb2875
1 parent
7a43e250
Exists in
master
and in
9 other branches
Fix ranking
Showing
1 changed file
with
2 additions
and
2 deletions
Show diff stats
lib/proposals_discussion_plugin/api.rb
... | ... | @@ -9,8 +9,8 @@ class ProposalsDiscussionPlugin::API < Grape::API |
9 | 9 | min_hits = article.proposals.minimum(:hits) |
10 | 10 | |
11 | 11 | proposals = article.proposals.map do |proposal| |
12 | - w = [(proposal.hits - max_hits).abs, (proposal.hits - min_hits).abs].max.to_f | |
13 | - effective_support = (proposal.votes_for - proposal.votes_against)/(1+w) | |
12 | + w = [(proposal.hits - max_hits).abs, (proposal.hits - min_hits).abs, 1].max.to_f | |
13 | + effective_support = (proposal.votes_for - proposal.votes_against)/w | |
14 | 14 | |
15 | 15 | {:id => proposal.id, :abstract => proposal.abstract, :votes_for => proposal.votes_for, :votes_against => proposal.votes_against, :hits => proposal.hits, :effective_support => effective_support} |
16 | 16 | end | ... | ... |