|
@@ -34,7 +34,13 @@ def write_csv(path_items, filename, data) |
|
|
FileUtils.mkdir_p(dir) |
|
|
FileUtils.mkdir_p(dir) |
|
|
@log.debug dir |
|
|
@log.debug dir |
|
|
fn = File.join(dir, filename + '.csv') |
|
|
fn = File.join(dir, filename + '.csv') |
|
|
File.write(fn, data) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
csv_string = CSV.generate do |csv| |
|
|
|
|
|
csv << data.first.keys # header row |
|
|
|
|
|
data.each { |row| csv << row.values } |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
File.write(fn, csv_string) |
|
|
@log.info fn |
|
|
@log.info fn |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
@@ -57,22 +63,11 @@ def gen_homepage |
|
|
write_page('.', 'index', { summary: summary }) |
|
|
write_page('.', 'index', { summary: summary }) |
|
|
|
|
|
|
|
|
# Summary CSV file |
|
|
# 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) |
|
|
|
|
|
|
|
|
write_csv('.', 'inlink-summary', summary) |
|
|
|
|
|
|
|
|
# Full CSV file |
|
|
# Full CSV file |
|
|
apps = ScraperWiki.select("* from applications") |
|
|
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) |
|
|
|
|
|
|
|
|
write_csv('.', 'inlink-full', apps) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def gen_new |
|
|
def gen_new |
|
@@ -96,15 +91,11 @@ def gen_authorities |
|
|
where authority_name = '#{auth['authority_name']}' |
|
|
where authority_name = '#{auth['authority_name']}' |
|
|
group by status, decision, appeal_status, appeal_decision |
|
|
group by status, decision, appeal_status, appeal_decision |
|
|
") |
|
|
") |
|
|
apps = ScraperWiki.select("* from applications where authority_name='#{auth['authority_name']}' order by date_received") |
|
|
|
|
|
write_page(['authorities', slug(auth['authority_name'])], 'authority', { apps: apps, auth: auth, summary: summary }) |
|
|
|
|
|
|
|
|
|
|
|
csv_string = CSV.generate do |csv| |
|
|
|
|
|
csv << apps.first.keys # header row |
|
|
|
|
|
apps.each { |app| csv << app.values } |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
apps = ScraperWiki.select("* from applications where authority_name='#{auth['authority_name']}' order by date_received") |
|
|
|
|
|
|
|
|
write_csv(['authorities', slug(auth['authority_name'])], slug(auth['authority_name']), csv_string) |
|
|
|
|
|
|
|
|
write_page(['authorities', slug(auth['authority_name'])], 'authority', { apps: apps, auth: auth, summary: summary }) |
|
|
|
|
|
write_csv(['authorities', slug(auth['authority_name'])], slug(auth['authority_name']), apps) |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|