Skip to content

Commit

Permalink
style: make suggested changes from PR review #260
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Jan 5, 2022
1 parent 7dd4fd2 commit 3afccd2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 9 additions & 6 deletions datagateway_api/src/search_api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def get_icat_mapping(self, panosc_entity_name, field_name):
"Output of get_icat_mapping(): %s, %s", panosc_entity_name, icat_field_name,
)

return (panosc_entity_name, icat_field_name)
return panosc_entity_name, icat_field_name

def __str__(self):
"""
Expand All @@ -130,18 +130,21 @@ def __str__(self):

if isinstance(self.search_api_query, SearchAPIQuery):
log.info("__str__ for SearchAPIWhereFilter, SearchAPIQuery found")
query = self.search_api_query

self.apply_filter(query)
self.apply_filter(self.search_api_query)
# Replicating the condition in Python ICAT format so it can be searched on
# the query and return as string representation
conds_dict = self.create_filter()
a, jpql_func = query.icat_query.query._split_db_functs(self.field)
conds_dict[self.field] = query.icat_query.query._cond_value(
a, jpql_func = self.search_api_query.icat_query.query._split_db_functs(
self.field,
)
conds_dict[self.field] = self.search_api_query.icat_query.query._cond_value(
conds_dict[self.field], jpql_func,
)

str_conds = query.icat_query.query.search_conditions(self.field, conds_dict)
str_conds = self.search_api_query.icat_query.query.search_conditions(
self.field, conds_dict,
)

try:
return str_conds[0]
Expand Down
4 changes: 1 addition & 3 deletions datagateway_api/src/search_api/query_filter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
SearchAPISkipFilter,
SearchAPIWhereFilter,
)
import datagateway_api.src.search_api.models as search_api_models
from datagateway_api.src.search_api.nested_where_filters import NestedWhereFilters
from datagateway_api.src.search_api.panosc_mappings import mappings
from datagateway_api.src.search_api.query import SearchAPIQuery
Expand Down Expand Up @@ -133,9 +134,6 @@ def get_where_filter(where_filter_input, entity_name):
elif list(where_filter_input.keys())[0] == "text":
log.debug("Text operator found within JSON where object")
try:
search_api_models = importlib.import_module(
"datagateway_api.src.search_api.models",
)
entity_class = getattr(search_api_models, entity_name)
except AttributeError as e:
raise SearchAPIError(
Expand Down

0 comments on commit 3afccd2

Please sign in to comment.