Skip to content

Commit

Permalink
add support for WHERE filters coming from count endpoints #259
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Nov 19, 2021
1 parent f56465c commit f9d1e57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 4 additions & 6 deletions datagateway_api/src/search_api/query_filter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,20 @@ def get_query_filter(request_filter):
raise FilterError(
"No valid filter name given within filter query param",
)

return query_filters
elif query_param_name == "where":
# For the count endpoints
"""
query_filters.extend(
SearchAPIQueryFilterFactory.get_query_filter(
{"filter": related_model["scope"]},
{"filter": request_filter},
),
),
"""
)
else:
raise FilterError(
f"Bad filter, please check query parameters: {request_filter}",
)

return query_filters

@staticmethod
def get_condition_values(filter_input):
where_filter_data = []
Expand Down
9 changes: 9 additions & 0 deletions test/search_api/test_search_api_query_filter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ class TestSearchAPIQueryFilterFactory:
["or", "or"],
id="OR, multiple conditions with operator",
),
pytest.param(
{"where": {"summary": {"like": "My Test Summary"}}},
1,
["summary"],
["like"],
["My Test Summary"],
["and"],
id="WHERE filter in syntax for count endpoints",
),
],
)
def test_valid_where_filter(
Expand Down

0 comments on commit f9d1e57

Please sign in to comment.