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.
 
 
 
 
 

42 lines
1.6 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. # New applications page
  14. apps = ScraperWiki.select("* from `applications` order by date_received desc limit 30")
  15. Petrify.write_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.write_page('decisions', 'decisions', { apps: apps })
  19. # Page and CSV file for each authority
  20. auths = ScraperWiki.select("distinct(authority_name) as authority_name from applications")
  21. auths.each do |auth|
  22. summary = ScraperWiki.select("
  23. status, decision, appeal_status, appeal_decision, count(*) as qty
  24. from applications
  25. where authority_name = ?
  26. group by status, decision, appeal_status, appeal_decision
  27. ", auth['authority_name'])
  28. apps = ScraperWiki.select("* from applications where authority_name = ? order by date_received", auth['authority_name'])
  29. path = ['authorities', slug(auth['authority_name'])]
  30. Petrify.write_page(path, 'authority', { apps: apps, auth: auth, summary: summary })
  31. Petrify.write_csv(path, slug(auth['authority_name']), apps)
  32. end
  33. end
  34. end