Performs ETL on courtbot data, provides a JSON API, produces insights and interactive data visualizations.
Currently-supported Courtbots include:
View the application in a browser and/or request JSON data from the API.
See source code for full documentation.
Returns a list of violation codes which have been cited the most.
/api/v0/top-violations.json
/api/v0/top-violations.json?limit=3
[
{"violation_id":"1", "violation_code":"40-6-20", "violation_description":"FAIL TO OBEY TRAF CTRL DEVICE", "citation_count":"3469"},
{"violation_id":"9", "violation_code":"40-2-8", "violation_description":"NO TAG/ NO DECAL", "citation_count":"2515"},
{"violation_id":"11", "violation_code":"40-8-76.1", "violation_description":"SAFETY BELT VIOLATION", "citation_count":"1960"}
]
Returns defendant counts per citation count.
/api/v0/defendant-citation-distribution.json
/api/v0/defendant-citation-distribution.json?limit=20
[
{"citation_count":"1","defendant_count":"130706"},
{"citation_count":"2","defendant_count":"29159"},
{"citation_count":"3","defendant_count":"8987"},
{"citation_count":"4","defendant_count":"3509"},
{"citation_count":"5","defendant_count":"1409"},
{"citation_count":"6","defendant_count":"678"},
{"citation_count":"7","defendant_count":"314"},
{"citation_count":"8","defendant_count":"170"},
{"citation_count":"9","defendant_count":"86"},
{"citation_count":"10","defendant_count":"61"},
{"citation_count":"11","defendant_count":"31"},
{"citation_count":"12","defendant_count":"19"},
{"citation_count":"13","defendant_count":"14"},
{"citation_count":"14","defendant_count":"5"},
{"citation_count":"15","defendant_count":"6"},
{"citation_count":"16","defendant_count":"2"},
{"citation_count":"17","defendant_count":"2"},
{"citation_count":"18","defendant_count":"4"},
{"citation_count":"19","defendant_count":"4"},
{"citation_count":"21","defendant_count":"1"}
]
Download source code and install package dependencies.
git clone [email protected]:codeforamerica/courtbot-reporter.git
cd courtbot-reporter
bundle install
Install ruby and bundler and rails.
Install postgresql.
Create user.
psql
CREATE USER courtbot_reporter WITH ENCRYPTED PASSWORD 'c0urtb0t!';
ALTER USER courtbot_reporter CREATEDB;
ALTER USER courtbot_reporter WITH SUPERUSER;
\q
Create database.
bundle exec rake db:create
Migrate database.
bundle exec rake db:migrate
Detect all possible Courtbot API endpoints.
bundle exec rake atlanta:detect
Extract .csv data from eligible Courtbot API endpoints.
bundle exec rake atlanta:extract
Create tests for new features.
Run all tests and make sure they pass before merging code into the master branch.
bundle exec rspec spec/
NOTE: Staging and production servers use different databases but share the same database credentials.
Update source code on staging (from master or another branch).
git push heroku-staging master
# OR ...
git push heroku-staging yourbranch:master
Debug as necessary.
Visit the application live at https://courtbot-reporter-staging.herokuapp.com/.
Update source code on production.
git push heroku-production master
Visit the application live at https://courtbot-reporter.herokuapp.com/.
Initiate a new PG Backup from the Heroku Postgres console and click "Download" when it's ready.
Restore production database on local machine.
psql
DROP DATABASE IF EXISTS courtbot_reporter_snapshot;
CREATE DATABASE courtbot_reporter_snapshot;
\q
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U courtbot_reporter -d courtbot_reporter_snapshot latest.dump