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.
 
 
 
 
 

62 lines
2.1 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. path = '.'
  11. Petrify.page(path, 'index', { summary: summary })
  12. Petrify.csv(path, 'inlink-summary', summary)
  13. # New applications page
  14. apps = ScraperWiki.select("* from `applications` order by date_received desc limit 30")
  15. Petrify.page('new-applications', 'new-applications', { apps: apps })
  16. # Latest decisions page
  17. apps = ScraperWiki.select("* from `applications` order by date_decision desc limit 30")
  18. Petrify.page('decisions', 'decisions', { apps: apps })
  19. # Appeals page
  20. summary = ScraperWiki.select("
  21. authority_name, appeal_status, appeal_decision, count(*) as applications
  22. from applications
  23. where appeal_status is not null
  24. and appeal_status != 'Unknown'
  25. group by authority_name, appeal_status, appeal_decision
  26. ")
  27. apps = ScraperWiki.select("
  28. * from applications
  29. where appeal_status is not null
  30. and appeal_status != 'Unknown'
  31. ")
  32. path = 'appeals'
  33. Petrify.page(path, 'appeals', { summary: summary, apps: apps })
  34. Petrify.csv(path, 'inlink-appeals', apps)
  35. # Authority pages
  36. auths = ScraperWiki.select("distinct(authority_name) as authority_name from applications")
  37. auths.each do |auth|
  38. summary = ScraperWiki.select("
  39. status, decision, appeal_status, appeal_decision, count(*) as qty
  40. from applications
  41. where authority_name = ?
  42. group by status, decision, appeal_status, appeal_decision
  43. ", auth['authority_name'])
  44. apps = ScraperWiki.select("* from applications where authority_name = ? order by date_received", auth['authority_name'])
  45. path = ['authorities', slug(auth['authority_name'])]
  46. Petrify.page(path, 'authority', { apps: apps, auth: auth, summary: summary })
  47. Petrify.csv(path, slug(auth['authority_name']), apps)
  48. end
  49. end
  50. end