Browse Source

Move path definition to where it's used

main
Adrian Short 6 years ago
parent
commit
31b98dad5e
1 changed files with 3 additions and 6 deletions
  1. +3
    -6
      lib/site.rb

+ 3
- 6
lib/site.rb View File

@@ -3,14 +3,13 @@ require 'scraperwiki'
class Site class Site
def self.generate def self.generate
# Home page # Home page
path = '.'

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
") ")


path = '.'
Petrify.page(path, 'index', { summary: summary }) Petrify.page(path, 'index', { summary: summary })
Petrify.csv(path, 'inlink-summary', summary) Petrify.csv(path, 'inlink-summary', summary)


@@ -23,8 +22,6 @@ class Site
Petrify.page('decisions', 'decisions', { apps: apps }) Petrify.page('decisions', 'decisions', { apps: apps })
# Appeals page # Appeals page
path = 'appeals'
summary = ScraperWiki.select(" summary = ScraperWiki.select("
authority_name, appeal_status, appeal_decision, count(*) as applications authority_name, appeal_status, appeal_decision, count(*) as applications
from applications from applications
@@ -39,6 +36,7 @@ class Site
and appeal_status != 'Unknown' and appeal_status != 'Unknown'
") ")
path = 'appeals'
Petrify.page(path, 'appeals', { summary: summary, apps: apps }) Petrify.page(path, 'appeals', { summary: summary, apps: apps })
Petrify.csv(path, 'inlink-appeals', apps) Petrify.csv(path, 'inlink-appeals', apps)


@@ -46,8 +44,6 @@ class Site
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|
path = ['authorities', slug(auth['authority_name'])]

summary = ScraperWiki.select(" summary = ScraperWiki.select("
status, decision, appeal_status, appeal_decision, count(*) as qty status, decision, appeal_status, appeal_decision, count(*) as qty
from applications from applications
@@ -57,6 +53,7 @@ class Site


apps = ScraperWiki.select("* from applications where authority_name = ? order by date_received", auth['authority_name']) apps = ScraperWiki.select("* from applications where authority_name = ? order by date_received", auth['authority_name'])


path = ['authorities', slug(auth['authority_name'])]
Petrify.page(path, 'authority', { apps: apps, auth: auth, summary: summary }) Petrify.page(path, 'authority', { apps: apps, auth: auth, summary: summary })
Petrify.csv(path, slug(auth['authority_name']), apps) Petrify.csv(path, slug(auth['authority_name']), apps)
end end


Loading…
Cancel
Save