Project that allows for searching for SPD police officers by badge, first_name, or last_name
- GET
/departments
- returns list of metadata on departments supported - GET
/seattle/metadata
- returns SPD metadata - GET
/seattle/officer
- expectsbadge
,first_name
and/orlast_name
to be provided as query parameters. An array of officers will be returned- if
badge
is provided, will look up officer in database by badge - else if either
first_name
orlast_name
, a name search will be performed on the database. Due to URL encoding,*
will be treated as a wildcard
- if
- GET
/seattle/officer/search
- expectsfirst_name
and/orlast_name
to be provided as query parameters. Invokes a fuzzy match based on name, array of officers returned are in descending match score - GET
/tacoma/metadata
- returns Tacoma PD metadata - GET
/tacoma/officer
- expectsfirst_name
and/orlast_name
to be provided as query parameters; name search will be performed on the database. Due to URL encoding,*
will be treated as a wildcard - GET
/tacoma/officer/search
- expectsfirst_name
and/orlast_name
to be provided as query parameters. Temporary route used to support Tacoma PD lookup
{
"badge": "6248",
"first_name": "Adrian",
"middle_name": "Z",
"last_name": "Diaz",
"title": "Interim Chief Of Police",
"unit": "A000",
"unit_description": "Cop - Chief Of Police"
}
{
"first_name": "Shawn",
"last_name": "Gustason",
"title": "Police Chief Asst",
"department": "Police",
"salary": "$309,881.46"
}
- prepare a
.env
file at the root containing entries forDB_USERNAME
andDB_PASSWORD
- run
docker-compose up --build
To start the server, the following environment variables need to be provided
DB_HOST
: database host nameDB_NAME
: database nameDB_USERNAME
: user to connect to databaseDB_PASSWORD
: password to connect to databasePORT
: port to listen for sample usage:
cd api
PORT=5000 \
DB_USERNAME=your_username \
DB_PASSWORD=your_password \
DB_NAME=your_db_name \
DB_HOST=your_db_host \
go run *.go
Quick script to read from a CSV file and load data into an officers table in a postgres database. Assumes seed csv file contains current SPD roster, as the script first clears the table before inserting values.
Script expects the following environment variables
SEED_FILE
: relative path to seed csv fileDB_HOST
: database host nameDB_NAME
: database nameDB_USERNAME
: user to connect to databaseDB_PASSWORD
: password to connect to database
sample usage:
cd db
SEED_FILE=csv/SPD_roster_11-15-20.csv \
DB_USERNAME=your_username \
DB_PASSWORD=your_password \
DB_NAME=your_db_name \
DB_HOST=your_db_host \
go run main.go