Skip to content

Commit

Permalink
Merge pull request #342 from ral-facilities/example-query-tests-#270
Browse files Browse the repository at this point in the history
Add Missing Endpoint Tests & Fix parameters.value bug
  • Loading branch information
MRichards99 authored Feb 28, 2022
2 parents 7985f33 + 2c21bab commit 6d5edf5
Show file tree
Hide file tree
Showing 3 changed files with 1,016 additions and 4 deletions.
15 changes: 11 additions & 4 deletions datagateway_api/src/search_api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,19 @@ def apply_filter(self, query):
# matters):
# {"Parameter": {"value": ["numericValue", "stringValue", "dateTimeValue"]}} # noqa: B950
if field_name == "value":
if isinstance(self.value, (int, float)):
# If the value is a list, extract the first value to determine which
# parameter value type should be used
if self.operation == "between" and isinstance(self.value, list):
filter_value = self.value[0]
else:
filter_value = self.value

if isinstance(filter_value, (int, float)):
icat_field_name = icat_field_name[0]
elif isinstance(self.value, datetime):
elif isinstance(filter_value, datetime):
icat_field_name = icat_field_name[2]
elif isinstance(self.value, str):
if DateHandler.is_str_a_date(self.value):
elif isinstance(filter_value, str):
if DateHandler.is_str_a_date(filter_value):
icat_field_name = icat_field_name[2]
else:
icat_field_name = icat_field_name[1]
Expand Down
Loading

0 comments on commit 6d5edf5

Please sign in to comment.