Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

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

Closed
chouinar opened this issue Jul 22, 2024 · 1 comment · Fixed by #168

Comments

@chouinar
Copy link
Collaborator

chouinar commented Jul 22, 2024

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
Copy link
Member

acouch commented Sep 17, 2024

Issue migrated to HHS#2056

@acouch acouch removed the Migrated label Sep 17, 2024
acouch pushed a commit 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
…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>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants