-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Basic Search API and Temporary UI #195
Conversation
so many logs
easier to search in place to incident type
Add a field for the handling department, and place the perpetrator in the officer's last name
Visit the preview URL for this PR (updated for commit alexjball/police-data-trust@20008f4): https://police-data-trust-dev--pr195-basic-search-0q9d6qjk.web.app (expires Wed, 27 Oct 2021 00:29:47 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 89ee28768ddf114979e2cf8eddd3746214cf93af |
|
||
bp = Blueprint("incident_routes", __name__, url_prefix="/api/v1/incidents") | ||
|
||
|
||
@bp.route("/get/<int:incident_id>", methods=["GET"]) | ||
@jwt_required() | ||
@role_required(UserRole.PUBLIC) |
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.
Hmmm, the way this annotation is implemented right now means that only users with the role public can make this request. Since our roles have a hierarchy, should we change this to mean public or higher?
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.
Yeah, that change makes sense! Created #196 to track
class SearchIncidentsSchema(BaseModel, extra="forbid"): | ||
location: Optional[str] = None | ||
startTime: Optional[datetime] = None | ||
endTime: Optional[datetime] = None | ||
description: Optional[str] = None | ||
page: Optional[int] = 1 | ||
perPage: Optional[int] = 20 |
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 think our schema definitions are getting a little disorganized, right now we have backend/schemas.py
, a single file with a few different unrelated schemas in it, and the files within backend/dto
as well. I don't know flask/python well enough to suggest a better system, but it seems like we might want one soon
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.
Yeah these can definitely be cleaned up. Most of the models in this file are unused. These schemas and the routes make up the public-facing API that will be used by partners and the web app, so we'll also want to be able to version and publish the api spec implied by these schemas. #111 sort of tracks that.
<section style={{ maxWidth: "500px", margin: "1em auto" }}> | ||
<h1>Search Incidents</h1> | ||
<FormProvider {...form}> | ||
<form className={sharedStyles.centerContent} onSubmit={form.handleSubmit(onSubmit)}> |
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.
this is temp UI? we should not be using forms onSubmit method, only the
tag itself but if temp ui then can ignorThere 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.
@JMStudiosJoe Can you explain why? We use onSubmit in all the other forms (registration, passport, login). We're using react-hook-form for control flow not raw html.
Closes #191, #113
POST /api/v1/incidents/search
that supports searching by location keyword, description keyword, and date range. keyword search is strictly a substring search, and there is no geocoding of the location.behaviors
test inregister.test.tsx
. We can add that when we start adding the actual UI components