Skip to content

Commit

Permalink
refactor: clean up SearchAPIQueryFilterFactory #259
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Dec 6, 2021
1 parent 605315c commit 4134a16
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions datagateway_api/src/search_api/query_filter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,23 @@ def get_where_filter(filter_input, entity_name):
):
boolean_operator = list(filter_input.keys())[0]
conditions = list(filter_input.values())[0]
test_where_filters = []
conditional_where_filters = []

for condition in conditions:
# Could be nested AND/OR
where_filter = {
"filter": {"where": condition},
}
conditional_where_filters = SearchAPIQueryFilterFactory.get_query_filter(
where_filter, entity_name,
conditional_where_filters.extend(
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)

print(f"test Cond where filters: {test_where_filters}")

nested = NestedWhereFilters(
test_where_filters[:-1], test_where_filters[-1], boolean_operator,
conditional_where_filters[:-1],
conditional_where_filters[-1],
boolean_operator,
)
where_filters.append(nested)
elif list(filter_input.keys())[0] == "text":
Expand Down

0 comments on commit 4134a16

Please sign in to comment.