Skip to content

Commit

Permalink
add initial usage of `NestedWhereFilters into query params factory cl…
Browse files Browse the repository at this point in the history
…ass #259
  • Loading branch information
MRichards99 committed Dec 2, 2021
1 parent 0c4f9ac commit 2114858
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions datagateway_api/src/search_api/query_filter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
SearchAPISkipFilter,
SearchAPIWhereFilter,
)
from datagateway_api.src.search_api.nested_where_filters import NestedWhereFilters

log = logging.getLogger()

Expand Down Expand Up @@ -62,6 +63,8 @@ def get_where_filter(filter_input, entity_name):
):
boolean_operator = list(filter_input.keys())[0]
conditions = list(filter_input.values())[0]
test_where_filters = []

for condition in conditions:
# Could be nested AND/OR
where_filter = {
Expand All @@ -70,10 +73,19 @@ def get_where_filter(filter_input, entity_name):
conditional_where_filters = SearchAPIQueryFilterFactory.get_query_filter(
where_filter, entity_name,
)
# TODO - could just go to extend the function call?
test_where_filters.extend(conditional_where_filters)

# for conditional_where_filter in conditional_where_filters:
# conditional_where_filter.boolean_operator = boolean_operator
# where_filters.extend(conditional_where_filters)

for conditional_where_filter in conditional_where_filters:
conditional_where_filter.boolean_operator = boolean_operator
where_filters.extend(conditional_where_filters)
print(f"test Cond where filters: {test_where_filters}")

nested = NestedWhereFilters(
test_where_filters[:-1], test_where_filters[-1], boolean_operator,
)
where_filters.append(nested)
elif list(filter_input.keys())[0] == "text":
# TODO - we might want to move this to the data
# definitions at a later point
Expand Down

0 comments on commit 2114858

Please sign in to comment.