Skip to content

Commit

Permalink
[Issue #2177] Fix facet count name issue
Browse files Browse the repository at this point in the history
  • Loading branch information
chouinar committed Sep 19, 2024
1 parent eaaee23 commit 72342dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/src/services/opportunities_v1/search_opportunities.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _add_search_filters(
def _add_aggregations(builder: search.SearchQueryBuilder) -> None:
# TODO - we'll likely want to adjust the total number of values returned, especially
# for agency as there could be hundreds of different agencies, and currently it's limited to 25.
builder.aggregation_terms("opportunity_status", _adjust_field_name("applicant_type"))
builder.aggregation_terms("opportunity_status", _adjust_field_name("opportunity_status"))
builder.aggregation_terms("applicant_type", _adjust_field_name("applicant_type"))
builder.aggregation_terms("funding_instrument", _adjust_field_name("funding_instrument"))
builder.aggregation_terms("funding_category", _adjust_field_name("funding_category"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1288,3 +1288,20 @@ def test_search_query_200(self, client, api_auth_token, search_request, expected
# This test isn't looking to validate opensearch behavior, just that we've connected fields properly and
# results being returned are as expected.
call_search_and_validate(client, api_auth_token, search_request, expected_results)

def test_search_query_facets_200(self, client, api_auth_token):
search_response = client.post(
"/v1/opportunities/search",
json=get_search_request(),
headers={"X-Auth": api_auth_token},
)

assert search_response.status_code == 200
facet_counts = search_response.get_json()["facet_counts"]
assert facet_counts.keys() == {
"agency",
"applicant_type",
"funding_instrument",
"funding_category",
"opportunity_status",
}

0 comments on commit 72342dc

Please sign in to comment.