Planning applications tracker for InLinkUK from BT kiosks. https://kiosks.adrianshort.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

46 lines
1.7 KiB

  1. require 'scraperwiki'
  2. class Site
  3. def self.generate
  4. # Home page
  5. summary = ScraperWiki.select("
  6. authority_name, status, decision, appeal_status, appeal_decision, count(*) as applications
  7. from applications
  8. group by authority_name, status, decision, appeal_status, appeal_decision
  9. ")
  10. Petrify.write_page('.', 'index', { summary: summary })
  11. # Summary CSV file
  12. Petrify.write_csv('.', 'inlink-summary', summary)
  13. # Full CSV file
  14. apps = ScraperWiki.select("* from applications")
  15. Petrify.write_csv('.', 'inlink-full', apps)
  16. # New applications page
  17. apps = ScraperWiki.select("* from `applications` order by date_received desc limit 30")
  18. Petrify.write_page('new-applications', 'new', { apps: apps })
  19. # Latest decisions page
  20. apps = ScraperWiki.select("* from `applications` order by date_decision desc limit 30")
  21. Petrify.write_page('decisions', 'decisions', { apps: apps })
  22. # Page and CSV file for each authority
  23. auths = ScraperWiki.select("distinct(authority_name) as authority_name from applications")
  24. auths.each do |auth|
  25. summary = ScraperWiki.select("
  26. status, decision, appeal_status, appeal_decision, count(*) as qty
  27. from applications
  28. where authority_name = ?
  29. group by status, decision, appeal_status, appeal_decision
  30. ", auth['authority_name'])
  31. apps = ScraperWiki.select("* from applications where authority_name = ? order by date_received", auth['authority_name'])
  32. path = ['authorities', slug(auth['authority_name'])]
  33. Petrify.write_page(path, 'authority', { apps: apps, auth: auth, summary: summary })
  34. Petrify.write_csv(path, slug(auth['authority_name']), apps)
  35. end
  36. end
  37. end