Election results in the London Borough of Sutton.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

30 lines
699 B

  1. require_relative "../models"
  2. # We should be checking polls.seats not districts.seats
  3. @res = repository(:default).adapter.select("
  4. SELECT c.election_id,
  5. c.district_id,
  6. c.party_id,
  7. COUNT(c.*) AS qty_candidacies
  8. FROM candidacies c,
  9. districts d
  10. WHERE c.district_id = d.id
  11. GROUP BY c.election_id,
  12. c.district_id,
  13. c.party_id,
  14. d.seats
  15. HAVING COUNT(c.*) > d.seats
  16. ")
  17. if @res.size > 0
  18. puts "ERROR: %d districts have too many candidates standing for one party" % @res.size
  19. exit 1
  20. else
  21. puts "OK: All districts have no more candidates standing per party than there are seats."
  22. exit 0
  23. end