-
Notifications
You must be signed in to change notification settings - Fork 13
Add q=
free text param to facilities API endpoint
#675
Conversation
@@ -131,7 +132,7 @@ class FilterSidebar extends Component { | |||
case filterSidebarTabsEnum.guide: | |||
return <FilterSidebarGuideTab />; | |||
case filterSidebarTabsEnum.search: | |||
return <FilterSidebarSearchTab />; | |||
return <Route component={FilterSidebarSearchTab} />; |
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 was done to have history.push
available in the mapDispatchToProps
function.
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.
Consider an inline comment explaining our reasoning.
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.
The code looks good. I don't have a dev environment up and running yet, so I have not exercised it.
src/django/api/views.py
Outdated
coreapi.Field( | ||
name='name', | ||
location='query', | ||
type='string', | ||
required=False, | ||
description='Facility Name', | ||
description='Facility Name or OAR ID', |
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.
Consider adding DEPRECATED. Use "q" instead.
to the description.
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.
Sounds good. I added this in 56208cf
None) | ||
free_text_query = request.query_params.get(FacilitiesQueryParams.Q, | ||
None) | ||
name = request.query_params.get(FacilitiesQueryParams.NAME, None) |
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.
Consider adding an inline comment explaining that name
is deprecated in favor of q
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.
👍 Added in 56208cf
if name is not None: | ||
queryset = queryset.filter(name__icontains=name) | ||
queryset = queryset.filter(Q(name__icontains=name) | |
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.
Consider adding an inline comment explaining that name
is deprecated in favor of q
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.
👍 see 56208cf
src/app/src/actions/facilities.js
Outdated
).length === 1; | ||
|
||
if (responseHasOnlyOneFacility) { | ||
flow( |
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.
Consider this more procedural version that makes sure we don't push an invalid route and alerts us to a problem.
const id = get(data, `features[0].id`, '')
if (id) {
pushNewRoute(makeFacilitiesDetailLink(id))
} else {
// Raise an exception that we will see in Rollbar
}
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.
Sounds good -- this is in 7327ad1
Since the code is in a promise the existing catch
will handle the thrown error.
@@ -131,7 +132,7 @@ class FilterSidebar extends Component { | |||
case filterSidebarTabsEnum.guide: | |||
return <FilterSidebarGuideTab />; | |||
case filterSidebarTabsEnum.search: | |||
return <FilterSidebarSearchTab />; | |||
return <Route component={FilterSidebarSearchTab} />; |
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.
Consider an inline comment explaining our reasoning.
I added the comment in a3c186c |
q=
free text param to facilities API endpointq=
free text param to facilities API endpoint
- Add `q=` free text param to facilities API endpoint - Update client to use `q=` param - Enable searches using `q` or `name` to search both name and OAR ID fields - Update client search input labels to indicate searches happen over names and OAR IDs
If only one facility returns in the search response, push the details page for that facility. (The search tab will remain populated on clicking back.)
11338cc
to
d201bdd
Compare
I rebased this on |
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.
Works well.
Thanks! |
Overview
q=
free text param to facilities API endpointq=
paramq
orname
to search both name and OAR IDfields
names and OAR IDs
Connects #121
Demo
Notes
This currently uses
id__icontains=q
for the OAR ID which means that it'll return both 1 result which exactly matches the input OAR ID if it's a full OAR ID or any results that match a partial OAR ID. This is the logic we used for the name search, too.I'm happy to make it an exact match but it seemed useful to have both available.
Testing Instructions
./scripts/resetdb
US2019
) and verify that that returns a list of resultsChecklist
fixup!
commits have been squashed