Skip to content
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

[Issue #3448] Create API endpoint for POST /users/:userID/save-searches #3472

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

mikehgrantsgov
Copy link
Collaborator

Summary

Fixes #3448

Time to review: 15 mins

Changes proposed

Add POST endpoint to create a saved search including routes and schemas.
Add supporting tests.

Context for reviewers

Supports the saved search requirements.

Additional information

See attached unit tests.

Comment on lines 97 to 103
search_query = fields.Dict(
required=True,
metadata={
"description": "The search query parameters to save",
"example": {"keywords": "search", "location": "Foo, Bar"},
},
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have this be the actual schema we use in the search endpoint? Just to make sure it's valid.

Also want to make sure the JSON serialization works with a full search request object for things like enums and dates.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added something to the test using get_search_request(). Something like this you have in mind?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking we would do search_query = fields.Nested(OpportunitySearchRequestV1Schema) - that way we can only take in a schema that is valid for search. Anything that isn't a valid search request should be rejected (eg. a user couldn't just pass {"some_field": "whatever"}.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked in the changes. This makes me wonder if we should also store the version of the search request schema for validation later. If, for example, we want the response to correspond to the schema that was inputted. It would be able to handle schema changes (and we could just output a dict response type validated against the stored schema version in a new db column. Otherwise we would not be able to validate response schema if this OpportunitySearchRequestV1Schema changes.

api/src/api/users/user_routes.py Outdated Show resolved Hide resolved
api/src/api/users/user_routes.py Outdated Show resolved Hide resolved
api/src/api/users/user_routes.py Outdated Show resolved Hide resolved
Comment on lines 97 to 103
search_query = fields.Dict(
required=True,
metadata={
"description": "The search query parameters to save",
"example": {"keywords": "search", "location": "Foo, Bar"},
},
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking we would do search_query = fields.Nested(OpportunitySearchRequestV1Schema) - that way we can only take in a schema that is valid for search. Anything that isn't a valid search request should be rejected (eg. a user couldn't just pass {"some_field": "whatever"}.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create API endpoint for POST /users/:userID/save-searches
3 participants