sc3 / cookcountyjail

A Django app that tracks the population of Cook County Jail over time and summarizes trends.
http://cookcountyjail.recoveredfactory.net/api/1.0/?format=json
Other
31 stars 23 forks source link

major refactoring of project files/folders, preparing django app to coexist /w v2.0 API #342

Closed bepetersn closed 10 years ago

bepetersn commented 10 years ago

In general, these changes are either:

1) thinning the django app and removing unnecessary files.

admin.py, views.py have been deleted altogether; settings.py, wsgi.py are now in the django app proper under countyapi/; and the old top-level urls.py was merged with the one under countyapi/. The result is that we no longer have the useless cookcountyjail directory under project root. Slightly less necessarily, I also deleted django's tests.py. The only things it had in it were tests for POST functionality, which we don't actually use. Perhaps least necessarily, data/bootstrap.sql was also removed... it seems like it was there for initializing an empty database, but I've never heard anyone mention it, or seen it referenced in our code. It can be brought back if anyone cares about it.

2) externalizing the django app as much as possible, thus making the project root a more viable home for components/code.

The big one here is the scraper, which is a top-level component, in the project root. In addition, I moved utils.py to the project root, under the supposition that it might be useful to a django app or a flask app equally. Finally, I took care to pull the classes that the scraper uses that are django ORM specific back into countyapi/. This will allow us to make comparable classes for the Flask API, hook them into the scraper, and have everything just work.

3) just setting up a better overall project structure for the future.

cron.sh and gunicorn.sh were moved into scripts, where they probably belonged in the first place. The templates/ directory has changed to static/, and could hold css, js, or just html used by any application associated with this project. I also moved the tests into two different directories, one for django API related classes, and the other for purely scraper-related classes. Oh, also deleted the AWS notification scripts, as I have figured out a better way to handle notifying.

All the resultant code from these refactorings allows the django server to run, and passes all tests. This was the best I could do for seeing that nothing was broken, but I wouldn't be surprised if there were another bug, even though I knew where to look for some of them.