uses proposal total_votes for % helper methods

This commit is contained in:
Juanjo Bazán
2015-12-18 13:15:00 +01:00
parent 3f195d6234
commit cf271fe33a
2 changed files with 12 additions and 2 deletions

View File

@@ -3,13 +3,13 @@ module ProposalsHelper
def progress_bar_percentage(proposal)
case proposal.cached_votes_up
when 0 then 0
when 1..Proposal.votes_needed_for_success then (proposal.cached_votes_up.to_f * 100 / Proposal.votes_needed_for_success).floor
when 1..Proposal.votes_needed_for_success then (proposal.total_votes.to_f * 100 / Proposal.votes_needed_for_success).floor
else 100
end
end
def supports_percentage(proposal)
percentage = (proposal.cached_votes_up.to_f * 100 / Proposal.votes_needed_for_success)
percentage = (proposal.total_votes.to_f * 100 / Proposal.votes_needed_for_success)
case percentage
when 0 then "0%"
when 0..(0.1) then "0.1%"