Planning applications tracker for InLinkUK from BT kiosks. https://kiosks.adrianshort.org/
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

site.rb 2.2 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. require 'scraperwiki'
  2. require 'petrify'
  3. class Site
  4. def self.generate
  5. # Home page
  6. summary = ScraperWiki.select("
  7. authority_name, status, decision, appeal_status, appeal_decision, count(*) as applications
  8. from applications
  9. group by authority_name, status, decision, appeal_status, appeal_decision
  10. ")
  11. path = '.'
  12. Petrify.page(path, 'index', { summary: summary })
  13. Petrify.csv(path, 'inlink-summary', summary)
  14. # New applications page
  15. apps = ScraperWiki.select("* from `applications` order by date_received desc limit 30")
  16. Petrify.page('new-applications', 'new-applications', { apps: apps })
  17. # Latest decisions page
  18. apps = ScraperWiki.select("* from `applications` order by date_decision desc limit 30")
  19. path = 'decisions'
  20. Petrify.page(path, 'decisions', { apps: apps })
  21. Petrify.csv(path, 'inlink-decisions', apps)
  22. # Appeals page
  23. summary = ScraperWiki.select("
  24. authority_name, appeal_status, appeal_decision, count(*) as applications
  25. from applications
  26. where appeal_status is not null
  27. and appeal_status != 'Unknown'
  28. group by authority_name, appeal_status, appeal_decision
  29. ")
  30. apps = ScraperWiki.select("
  31. * from applications
  32. where appeal_status is not null
  33. and appeal_status != 'Unknown'
  34. ")
  35. path = 'appeals'
  36. Petrify.page(path, 'appeals', { summary: summary, apps: apps })
  37. Petrify.csv(path, 'inlink-appeals', apps)
  38. # Authority pages
  39. auths = ScraperWiki.select("distinct(authority_name) as authority_name from applications")
  40. auths.each do |auth|
  41. summary = ScraperWiki.select("
  42. status, decision, appeal_status, appeal_decision, count(*) as qty
  43. from applications
  44. where authority_name = ?
  45. group by status, decision, appeal_status, appeal_decision
  46. ", auth['authority_name'])
  47. apps = ScraperWiki.select("* from applications where authority_name = ? order by date_received", auth['authority_name'])
  48. path = ['authorities', slug(auth['authority_name'])]
  49. Petrify.page(path, 'authority', { apps: apps, auth: auth, summary: summary })
  50. Petrify.csv(path, slug(auth['authority_name']), apps)
  51. end
  52. end
  53. end