-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API endpoints for departments #1138
base: develop
Are you sure you want to change the base?
Conversation
OpenOversight/app/api/v1/api.py
Outdated
@v1.route("/departments/<int:department_id>/officers", methods=[HTTPMethod.GET]) | ||
def download_dept_officers(department_id: int): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using one of the formats here: #385 (comment)
Thoughts, @sea-kelp @abandoned-prototype @b-meson @AetherUnbound?
## Description of Changes Addressed inconsistencies with the model `__repr__` functions. Mostly making this because this PR got a bit out of control: #1138 ## Tests and Linting - [x] This branch is up-to-date with the `develop` branch. - [x] `pytest` passes on my local development environment. - [x] `pre-commit` passes on my local development environment.
## Fixes issue Sets the groundwork for this issue: #385 ## Description of Changes Simplifying the import logic for the `auth` and `main` routes of the application. This also sets up the work for this PR: #1138 ## Tests and Linting - [x] This branch is up-to-date with the `develop` branch. - [x] `pytest` passes on my local development environment. - [x] `pre-commit` passes on my local development environment.
cache_params = (Department(id=department_id), KEY_DEPT_ALL_NOTES) | ||
notes = get_database_cache_entry(*cache_params) | ||
|
||
if notes is None: | ||
notes = ( | ||
db.session.query(Description) | ||
.join(Description.officer) | ||
.filter(Officer.department_id == department_id) | ||
.options(contains_eager(Description.officer)) | ||
.all() | ||
) | ||
put_database_cache_entry(*cache_params, notes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth moving these to static functions on each of the objects since they are used both here and in views.
Things that might be needed, are documentation for these endpoints. I'm not sure what a good protocol is for that rn, though I'm welcome to suggestions. |
resp_assignments = client.get( | ||
url_for("v1.get_dept_assignments", department_id=department_id), | ||
follow_redirects=True, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could probably get rid of follow_redirects
, but I think it might be worth keeping in case we modify the endpoint at some point.
Fixes issue
#385
Description of Changes
Add the baseline features for a data-focused API.
Tests and Linting
develop
branch.pytest
passes on my local development environment.pre-commit
passes on my local development environment.