Dinesafe Toronto API
see doc/TODO.md for todo items
cp config/settings.example.yml config/settings.yml,
and add your own CMS username/password.
Transferring The Database
Dump Database - Production
pg_dump -U postgres -h localhost dinesafe_production -f ~/db_dumps/dinesafe_production_$(date +%Y-%m-%d).dump --password --format=c
Download Database - Production
rsync --partial --progress --rsh=ssh <user>@<hostname>:~/db_dumps/<filename>.dump db/dumps/
pg_dump -U mruten dinesafe_dev -f doc/database_dumps/dinesafe_dev_$(date +%Y-%m-%d).dump --format=c
pg_restore -d database_name doc/database_dumps/filename.dump
NOTE: On production, make sure to switch to postgres user.
Update Sitemap XML
It's important to update the sitemap.xml file for SEO purposes.
Run this on server to generate sitemap and ping search engines:
Or, generate sitemap but don't ping search engines:
TODO: Move sitemap updating to a cron job.
Run this to update all Dinesafe data:
Or, you can run individual tasks as needed.
Update XML from Toronto Open Data:
Import XML to database (will only add/update changed records):
Geocode addresses that need it (updates geocodes table):
Update establishment addresses from geocodes (and create blank Geocodes for unknown addresses):
Fix typos (based on list of manual fixes in task):
You can use Vagrant to run the app in a virtual machine.
- Install Vagrant, Parallels. (With some modification, could use VirtualBox instead.)
vagrant plugin install vagrant-librarian-chef-nochef
vagrant plugin install vagrant-parallels
Then run these commands on the VM:
vagrant sshto connect to the VM
sudo -u postgres psql -d template1 -c "ALTER USER postgres WITH PASSWORD 'password';"
bundle exec rake db:setup
bundle exec rake dinesafe:update_data
Toronto Open Data
For convenience, info from this link has been copied below.
Owner Public Health - Healthy Environments Program
Currency Current - updated bi-weekly
ROW_ID - Represents the Row Number
ESTABLISHMENT_ID – Unique identifier for an establishment
INSPECTION_ID - Unique identifier for each Inspection
ESTABLISHMENT_NAME – Business name of the establishment
ESTABLISHMENTTYPE – Establishment type ie restaurant, mobile cart
ESTABLISHMENT_ADDRESS – Municipal address of the establishment
ESTABLISHMENT_STATUS – Pass, Conditional Pass, Closed
MINIMUM_INSPECTIONS_PERYEAR – Every eating and drinking establishment in the City of Toronto receives a minimum of 1, 2, or 3 inspections each year depending on the specific type of establishment, the food preparation processes, volume and type of food served and other related criteria
INFRACTION_DETAILS – Description of the Infraction
INSPECTION_DATE – Calendar date the inspection was conducted
SEVERITY – Level of the infraction, i.e. S – Significant, M – Minor, C – Crucial
ACTION – Enforcement activity based on the infractions noted during a food safety inspection
COURT_OUTCOME – The registered court decision resulting from the issuance of a ticket or summons for outstanding infractions to the Health Protection and Promotion Act
AMOUNT_FINED – Fine determined in a court outcome
The data set is as current as the date of the extraction. It is not a substitute for the notification and posting requirements of Municipal Code Chapter 545 - Licensing.
Contact Open Data Team email@example.com