X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/80fe90c787f595b0554297d2fe5eb810e3ca652a..46f924b34b305d2474b09ce204a7a9187e8d8622:/app/controllers/quickvote_controller.rb diff --git a/app/controllers/quickvote_controller.rb b/app/controllers/quickvote_controller.rb index f5ab581..acbf012 100644 --- a/app/controllers/quickvote_controller.rb +++ b/app/controllers/quickvote_controller.rb @@ -143,33 +143,8 @@ class QuickvoteController < ApplicationController def results @election = ident_to_quickvote(params[:ident]) - - # initalize the tallies to empty arrays - preference_tally = Array.new - plurality_tally = Array.new - approval_tally = Array.new - - @election.voters.each do |voter| - # skip if the voter has not voted or has an unconfirmed vote - next unless voter.voted? - - plurality_tally << voter.vote.rankings.sort[0].candidate.id - approval_tally << voter.vote.rankings.sort[0..1].collect \ - { |ranking| ranking.candidate.id } - preference_tally << voter.vote.rankings.sort.collect \ - { |ranking| ranking.candidate.id } - end - - @plurality_result = PluralityVote.new(plurality_tally).result - @approval_result = ApprovalVote.new(approval_tally).result - @condorcet_result = PureCondorcetVote.new(preference_tally).result - @ssd_result = CloneproofSSDVote.new(preference_tally).result - @borda_result = BordaVote.new(preference_tally).result - #@runoff_result = InstantRunoffVote.new(preference_tally).result - #@runoff_results = PluralityVote.new(preference_tally).result - - - @candidates = {} + @election.results + @candidates = {} @election.candidates.each {|c| @candidates[c.id] = c} end