- #Calculate Election Results
- def results
- # initalize the tallies to empty arrays
- preference_tally = Array.new
- plurality_tally = Array.new
- approval_tally = Array.new
-
- self.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 }
+ ### Convert a shortname or id into a QuickVote
+ def self.ident_to_quickvote(ident)
+ return nil unless ident
+ if ident.match(/^\d+$/)
+ quickvote = QuickVote.find(ident)
+ else
+ quickvote = QuickVote.find(:all, :conditions => ["name = ?", ident])[0]