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

[Task]: Add the ability to query the search endpoint by post and close date ranges (search v1) #2056

Closed
acouch opened this issue Sep 17, 2024 · 0 comments
Labels

Comments

@acouch
Copy link
Collaborator

acouch commented Sep 17, 2024


Migrated from navapbc#163
Originally created by @chouinar on Mon, 22 Jul 2024 16:56:28 GMT


Summary

NOTE: This ticket won't implement the query to the search index, but is just modifying the API schema, a follow-up PR will be created to fully connect this work.

We want to add the ability to filter specific date fields in our search endpoint.

For context, our search endpoints request looks like:

{
  "filters": {
    "agency": {
      "one_of": [
        "USAID",
        "ARPAH"
      ]
    },
    "applicant_type": {
      "one_of": [
        "state_governments",
        "county_governments",
        "individuals"
      ]
    },
  },
  "pagination": {
    "order_by": "opportunity_id",
    "page_offset": 1,
    "page_size": 25,
    "sort_direction": "descending"
  },
  "query": "research"
}

We want to support a new set of filters for that will look like:

{
    "post_date": {
          "start_date": "2024-01-01",
          "end_date": "2024-02-01"
    },
    "close_date": {
          "start_date": "2024-01-01",
    },
}

Start and end date will both be optional fields that can be null (we'll treat missing/null as an open-ended range).


To make this change, we'll need to modify our OpportunitySearchFilterV1Schema class to have these fields, and configure the allowed fields within the models. Rather than manually define the schemas which would require a lot of additional classes, we can generate the schemas following a similar pattern to how we generate the string search parameters in StrSearchSchemaBuilder, but for dates instead.

Acceptance criteria

  • Search request schema is updated (specifically the v1 opportunity search endpoint, ignore v0+v0.1)
  • Example requests (defined in opportunity_routes) have been updated, just need to update the "all filters" one.
  • Basic unit tests have been added to the opportunity search tests to validate the validations work
    • null values allowed
    • fields not being set allowed
    • errors if you pass in an incorrect type
@acouch acouch closed this as completed Sep 17, 2024
acouch pushed a commit to navapbc/simpler-grants-gov that referenced this issue Sep 18, 2024
…nt schema (navapbc/simpler-grants-govnavapbc/simpler-grants-gov#168)

Fixes HHS#2056

- Added .with_start_date to search_schema builder to allow building a
date field with key of "start_date"
- Added .with_end_date to search_schema builder to allow building a date
field with key of "end_date"
- Added post_date and close_date properties to
OpportunitySearchFilterV1Schema class, which utilize the above to build
schema filters for post_date and close_date which can utilize start_date
and/or end_date fields.
- Added two unit tests in test_opportunity_route_search that will test
the data validation of these new filters. One test is for 200 response
cases and the other test is for 422 (invalid) response cases.

Note: As noted in the AC of Issue #163, this PR does NOT include
implementation of the filters. Currently, these filters do nothing as
they haven't been tied to any sort of query. This PR is just to lay the
ground work.

---------

Co-authored-by: nava-platform-bot <platform-admins@navapbc.com>
acouch pushed a commit to navapbc/simpler-grants-gov that referenced this issue Sep 18, 2024
…nt schema (navapbc/simpler-grants-govnavapbc/simpler-grants-gov#168)

Fixes HHS#2056

- Added .with_start_date to search_schema builder to allow building a
date field with key of "start_date"
- Added .with_end_date to search_schema builder to allow building a date
field with key of "end_date"
- Added post_date and close_date properties to
OpportunitySearchFilterV1Schema class, which utilize the above to build
schema filters for post_date and close_date which can utilize start_date
and/or end_date fields.
- Added two unit tests in test_opportunity_route_search that will test
the data validation of these new filters. One test is for 200 response
cases and the other test is for 422 (invalid) response cases.

Note: As noted in the AC of Issue #163, this PR does NOT include
implementation of the filters. Currently, these filters do nothing as
they haven't been tied to any sort of query. This PR is just to lay the
ground work.

---------

Co-authored-by: nava-platform-bot <platform-admins@navapbc.com>
acouch pushed a commit that referenced this issue Sep 18, 2024
…schema (navapbc/simpler-grants-govnavapbc/simpler-grants-gov#168)

Fixes #2056

- Added .with_start_date to search_schema builder to allow building a
date field with key of "start_date"
- Added .with_end_date to search_schema builder to allow building a date
field with key of "end_date"
- Added post_date and close_date properties to
OpportunitySearchFilterV1Schema class, which utilize the above to build
schema filters for post_date and close_date which can utilize start_date
and/or end_date fields.
- Added two unit tests in test_opportunity_route_search that will test
the data validation of these new filters. One test is for 200 response
cases and the other test is for 422 (invalid) response cases.

Note: As noted in the AC of Issue #163, this PR does NOT include
implementation of the filters. Currently, these filters do nothing as
they haven't been tied to any sort of query. This PR is just to lay the
ground work.

---------

Co-authored-by: nava-platform-bot <platform-admins@navapbc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

1 participant