| @@ -49,8 +49,31 @@ def create_output_dir | |||||
| end | end | ||||
| def gen_homepage | 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 | def gen_new | ||||
| apps = ScraperWiki.select("* from `applications` order by date_received desc limit 30") | apps = ScraperWiki.select("* from `applications` order by date_received desc limit 30") | ||||
| @@ -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 | |||||
| | |||||
| - csv_fn = 'inlink-full.csv' | |||||
| %a.button{ :href => csv_fn, :download => csv_fn } | |||||
| Download full CSV data | |||||
| %table | %table | ||||
| %thead | %thead | ||||
| %tr | %tr | ||||
| %th Authority | %th Authority | ||||
| %th Reference | |||||
| %th Date | |||||
| %th Address | |||||
| %th Status | |||||
| %th Decision | %th Decision | ||||
| %th | |||||
| %th | |||||
| %th Applications | |||||
| %tbody | %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'] | |||||