| @@ -6,7 +6,8 @@ class Site | |||||
| def self.generate | def self.generate | ||||
| # Home page | # Home page | ||||
| summary = ScraperWiki.select(" | summary = ScraperWiki.select(" | ||||
| authority_name, status, decision, appeal_status, appeal_decision, count(*) as applications | |||||
| authority_name, status, decision, appeal_status, appeal_decision, | |||||
| count(*) as applications | |||||
| from applications | from applications | ||||
| group by authority_name, status, decision, appeal_status, appeal_decision | group by authority_name, status, decision, appeal_status, appeal_decision | ||||
| ") | ") | ||||
| @@ -20,15 +21,18 @@ class Site | |||||
| last_updated = DateTime.parse(q[0]['scraped_at']) | last_updated = DateTime.parse(q[0]['scraped_at']) | ||||
| path = '.' | path = '.' | ||||
| Petrify.page(path, 'index', { summary: summary, last_updated: last_updated }) | |||||
| Petrify.page(path, 'index', \ | |||||
| { summary: summary, last_updated: last_updated }) | |||||
| Petrify.csv(path, 'inlink-summary', summary) | Petrify.csv(path, 'inlink-summary', summary) | ||||
| # New applications page | # New applications page | ||||
| apps = ScraperWiki.select("* from `applications` order by date_received desc limit 60") | |||||
| apps = ScraperWiki.select("* from `applications` | |||||
| order by date_received desc limit 60") | |||||
| Petrify.page('new-applications', 'new-applications', { apps: apps }) | Petrify.page('new-applications', 'new-applications', { apps: apps }) | ||||
| # Latest decisions page | # Latest decisions page | ||||
| apps = ScraperWiki.select("* from `applications` order by date_decision desc limit 60") | |||||
| apps = ScraperWiki.select("* from `applications` | |||||
| order by date_decision desc limit 60") | |||||
| path = 'decisions' | path = 'decisions' | ||||
| Petrify.page(path, 'decisions', { apps: apps }) | Petrify.page(path, 'decisions', { apps: apps }) | ||||
| Petrify.csv(path, 'inlink-decisions', apps) | Petrify.csv(path, 'inlink-decisions', apps) | ||||
| @@ -61,7 +65,8 @@ class Site | |||||
| Petrify.page('media', 'media', { stories: stories }) | Petrify.page('media', 'media', { stories: stories }) | ||||
| # Authority pages | # Authority pages | ||||
| auths = ScraperWiki.select("distinct(authority_name) as authority_name from applications") | |||||
| auths = ScraperWiki.select("distinct(authority_name) as authority_name | |||||
| from applications") | |||||
| auths.each do |auth| | auths.each do |auth| | ||||
| summary = ScraperWiki.select(" | summary = ScraperWiki.select(" | ||||
| @@ -71,7 +76,8 @@ class Site | |||||
| group by status, decision, appeal_status, appeal_decision | group by status, decision, appeal_status, appeal_decision | ||||
| ", auth['authority_name']) | ", auth['authority_name']) | ||||
| apps = ScraperWiki.select("* from applications where authority_name = ? order by date_received desc", auth['authority_name']) | |||||
| apps = ScraperWiki.select("* from applications where authority_name = ? | |||||
| order by date_received desc", auth['authority_name']) | |||||
| this_stories = stories.select \ | this_stories = stories.select \ | ||||
| { |story| story['authorities'].match(auth['authority_name']) } | { |story| story['authorities'].match(auth['authority_name']) } | ||||