Election results in the London Borough of Sutton.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

sanity.rb 699 B

1234567891011121314151617181920212223242526272829
  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