Skip to content

Commit

Permalink
refactor: allow PythonICATSkipFilter to use Search API config #263
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Bozhinov committed Dec 2, 2021
1 parent 9266e85 commit 5ab60de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions datagateway_api/src/datagateway_api/icat/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,20 @@ def apply_filter(self, query):


class PythonICATSkipFilter(SkipFilter):
def __init__(self, skip_value):
def __init__(self, skip_value, client_use="datagateway_api"):
super().__init__(skip_value)
self.client_use = client_use

def apply_filter(self, query):
icat_properties = get_icat_properties(
config.datagateway_api.icat_url, config.datagateway_api.icat_check_cert,
)
if self.client_use == "datagateway_api":
icat_properties = get_icat_properties(
config.datagateway_api.icat_url, config.datagateway_api.icat_check_cert,
)
else:
icat_properties = get_icat_properties(
config.search_api.icat_url, config.search_api.icat_check_cert,
)

icat_set_limit(query, self.skip_value, icat_properties["maxEntities"])


Expand Down
2 changes: 1 addition & 1 deletion datagateway_api/src/search_api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def apply_filter(self, query):

class SearchAPISkipFilter(PythonICATSkipFilter):
def __init__(self, skip_value):
super().__init__(skip_value)
super().__init__(skip_value, client_use="search_api")

def apply_filter(self, query):
return super().apply_filter(query)
Expand Down

0 comments on commit 5ab60de

Please sign in to comment.