Planning applications tracker for InLinkUK from BT kiosks. https://kiosks.adrianshort.org/
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

site.rb 2.1 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.page('.', 'index', { summary: summary })
  11. # Summary CSV file
  12. Petrify.csv('.', '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. Petrify.page('appeals', 'appeals', { summary: summary, apps: apps })
  33. Petrify.csv('appeals', 'inlink-appeals', apps)
  34. # Page and CSV file for each authority
  35. auths = ScraperWiki.select("distinct(authority_name) as authority_name from applications")
  36. auths.each do |auth|
  37. summary = ScraperWiki.select("
  38. status, decision, appeal_status, appeal_decision, count(*) as qty
  39. from applications
  40. where authority_name = ?
  41. group by status, decision, appeal_status, appeal_decision
  42. ", auth['authority_name'])
  43. apps = ScraperWiki.select("* from applications where authority_name = ? order by date_received", auth['authority_name'])
  44. path = ['authorities', slug(auth['authority_name'])]
  45. Petrify.page(path, 'authority', { apps: apps, auth: auth, summary: summary })
  46. Petrify.csv(path, slug(auth['authority_name']), apps)
  47. end
  48. end
  49. end