Election results in the London Borough of Sutton.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

21 rinda
585 B

  1. require_relative '../models'
  2. require 'pp'
  3. # Set position and elected for each candidacy
  4. Election.all.each do |election|
  5. election.body.districts.each do |district|
  6. cands = Candidacy.all(:conditions => { :district_id => district.id, :election_id => election.id }, :order => [:votes.desc])
  7. pp cands
  8. puts
  9. pos = 1
  10. cands.each do |cand|
  11. pos <= district.seats ? seats = 1 : seats = 0
  12. print cand.candidate.surname, ' ', cand.votes, ' ', pos, ' ', seats, "\n"
  13. cand.position = pos
  14. cand.seats = seats
  15. cand.save
  16. pos += 1
  17. end
  18. end
  19. end