From 632db20485fc1d5a244cedc66b001a7fae088838 Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Wed, 19 Dec 2012 09:54:17 +0000 Subject: [PATCH] Add number of candidates in each district to districts contested table; make both tables easy to copy and paste --- app.rb | 3 ++- views/electionsummary.haml | 31 ++++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/app.rb b/app.rb index 67ae1ed..2d80ba5 100644 --- a/app.rb +++ b/app.rb @@ -118,7 +118,8 @@ get '/bodies/:body/elections/:date' do d.name, d.slug AS district_slug, SUM(c.seats) AS seats, - SUM(c.votes) AS votez + SUM(c.votes) AS votez, + COUNT(c.id) AS num_candidates FROM districts d, candidacies c diff --git a/views/electionsummary.haml b/views/electionsummary.haml index e108cad..dc2f515 100644 --- a/views/electionsummary.haml +++ b/views/electionsummary.haml @@ -50,8 +50,8 @@ %table %tr.header - %th - %th + %th   + %th   %th.highlight seats won %th votes %th % seats @@ -82,26 +82,25 @@ %tr.footer - %td - %td + %td   + %td   %td.right.highlight= @total_seats %td.right= commify(@total_votes) - %td - %td - %td - %td - %td - -# - %td + %td   + %td   + %td   + %td   + %td   %h2 - Results by - = @election.body.district_name + = @election.body.district_name.capitalize.pluralize(2) + contested in this election %table %tr.header - %th + %th   %th seats + %th candidates %th votes - @results_by_district.each do |row| %tr @@ -109,10 +108,12 @@ %a{ :href => "/bodies/#{@election.body.slug}/elections/#{@election.d}/#{@election.body.districts_name}/#{row.district_slug}"} = row.name %td.right= row.seats + %td.right= row.num_candidates %td.right= commify(row.votez) %tr.footer - %td + %td   %td.right= @total_seats + %td.right= @election.candidacies.count %td.right= commify(@total_votes) - else %p Full details and results will be available on this page.