Browse Source

Generate a summary rather than recent decisions on the homepage

main
Adrian Short 5 years ago
parent
commit
d52383206e
2 changed files with 52 additions and 18 deletions
  1. +25
    -2
      bin/build
  2. +27
    -16
      views/index.haml

+ 25
- 2
bin/build View File

@@ -49,8 +49,31 @@ def create_output_dir
end

def gen_homepage
decisions = ScraperWiki.select("* from `applications` order by date_decision desc limit 20")
write_page('.', 'index', { decisions: decisions })
summary = ScraperWiki.select("
authority_name, status, decision, appeal_status, appeal_decision, count(*) as applications
from applications
group by authority_name, status, decision, appeal_status, appeal_decision
")
write_page('.', 'index', { summary: summary })

# Summary CSV file
csv_string = CSV.generate do |csv|
csv << summary.first.keys # header row
summary.each { |row| csv << row.values }
end

write_csv('.', 'inlink-summary', csv_string)

# Full CSV file
apps = ScraperWiki.select("* from applications")
csv_string = CSV.generate do |csv|
csv << apps.first.keys # header row
apps.each { |app| csv << app.values }
end

write_csv('.', 'inlink-full', csv_string)
end

def gen_new
apps = ScraperWiki.select("* from `applications` order by date_received desc limit 30")


+ 27
- 16
views/index.haml View File

@@ -1,22 +1,33 @@
%h2 Latest decisions
%h1 Summary

%p.warning There are typically two applications per kiosk: one for full planning permission or telecoms prior approval, and one for advertisement consent. So the number of kiosks applied for is half the number of applications.

%p
- csv_fn = 'inlink-summary.csv'
%a.button{ :href => csv_fn, :download => csv_fn }
Download summary CSV data
&nbsp;
- csv_fn = 'inlink-full.csv'
%a.button{ :href => csv_fn, :download => csv_fn }
Download full CSV data

%table
%thead
%tr
%th Authority
%th Reference
%th Date
%th Address
%th Status
%th Decision
%th &nbsp;
%th &nbsp;
%th Applications
%tbody
- decisions.each do |app|
%tr
%td
%a{ :href => "/authorities/#{ slug(app['authority_name'])}" }
= app['authority_name']
%td
%a{ href: app['info_url']}
= app['council_reference']
%td= short_date(app['date_decision'])
%td= app['address']
%td= app['decision']
- summary.each do |row|
%tr
%td
%a{ href: authority_url(row['authority_name']) }
= row['authority_name']
%td= row['status']
%td= row['decision']
%td= cleanup(row['appeal_status'])
%td= cleanup(row['appeal_decision'])
%td.right= row['applications']

Loading…
Cancel
Save