An API that provides an interface to search complaint data.
- Search complaint data
- Suggest complaint data based on input
- Get complaint based on ID
Requirements are batch-installed via pip (see below).
- django - Web framework
- django-localflavor - Country-specific Django helpers
- djangorestframework - Rest API framework
- elasticsearch - low level client for Elasticsearch
- requests - http requests to get different data format
This repository assumes that you have an instance of elasticsearch running with complaint data set up and running.
If not, please refer to the CCDB Data Pipeline to load data into Elasticsearch.
This project uses environment variables and uses autoenv to automatically define environment variables and launch the virtualenv upon cding to the project folder.
You will need to install Autoenv if you haven't:
brew install autoenv
After installation, Homebrew will output instructions similar to:
To finish the installation, source activate.sh in your shell:
source /Users/[YOUR USERNAME]/homebrew/opt/autoenv/activate.sh
Run that now for your initial setup. Any time you run the project you’ll need to run that last line, so if you’ll be working with the project consistently, we suggest adding it to your Bash profile by running:
echo 'source /Users/[YOUR USERNAME]/homebrew/opt/autoenv/activate.sh' >> ~/.bash_profile
If you need to find this info again later, you can run:
brew info autoenv
You can then copy the .env_SAMPLE
file to .env
, then update any environment variables accordingly.
First, create a virtual environment for Python dependencies:
mkvirtualenv ccdb5-api
Next, use pip
to install dependencies, which are defined in setup.py
:
pip install -e '.[testing]'
With that, you just need a few additional commands to get up and running:
python manage.py runserver
Documentation for this repository is rendered via GitHub pages and Swagger. They can be edited in the docs/
directory, but to build or deploy them, you'll need to install docs requirements:
pip install -r docs_requirements.txt
You can then preview your changes locally by running mkdocs serve
and then reviewing http://127.0.0.1:8000/
When your changes are ready, you can submit them as a normal pull request. After that, you can use this command to publish them:
mkdocs gh-deploy --clean
That pushes the necessary files to the gh-pages
branch.
- The
mkdocs gh-deploy
command will push any edits you've made locally to thegh-pages
branch of the repository, whether you've committed them or not. - Mkdocs will create a "site" directory locally when you use either
build
,serve
orgh-deploy
. This is used to assemble assets to be pushed to the gh-pages branch, but thesite/
directory itself doesn't need to be under version control. It can be deleted after a deploy.
If you have Tox installed (recommended),
you can run the specs for this project with the tox
command.
If not, this command will run the specs on the python version your local
environment has installed: ./manage.py test
.
If you run the tests via Tox, it will automatically display spec coverage information. To get test coverage information outside of Tox, install Coverage.py and run these commands:
coverage erase
coverage run manage.py test
coverage report