Git Product home page Git Product logo

courtbot-reporter's Introduction

Courtbot Reporter

Performs ETL on courtbot data, provides a JSON API, produces insights and interactive data visualizations.

Currently-supported Courtbots include:

Usage

View the application in a browser and/or request JSON data from the API.

API Endpoints

See source code for full documentation.

Top Violations

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"}
]

Defendant Citation Distribution

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"}
]

Contributing

Installation

Download source code and install package dependencies.

git clone [email protected]:codeforamerica/courtbot-reporter.git
cd courtbot-reporter
bundle install

Prerequisites

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

Testing

Create tests for new features.

Run all tests and make sure they pass before merging code into the master branch.

bundle exec rspec spec/

Deploying

NOTE: Staging and production servers use different databases but share the same database credentials.

Staging

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/.

Production

Update source code on production.

git push heroku-production master

Visit the application live at https://courtbot-reporter.herokuapp.com/.

Maintenance

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

courtbot-reporter's People

Contributors

kuanb avatar s2t2 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.