Planning applications tracker for InLinkUK from BT kiosks. https://kiosks.adrianshort.org/
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

63 lignes
2.1 KiB

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