Skip to content

Commit

Permalink
add code to search endpoints to handle filters #260
Browse files Browse the repository at this point in the history
- This code has been added to manually test how the filters are working looking at an entire request from start to finish
  • Loading branch information
MRichards99 committed Dec 20, 2021
1 parent 34b1d81 commit 82ae018
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions datagateway_api/src/search_api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def get_icat_mapping(self, panosc_entity_name, field_name):
:return: Tuple containing the PaNOSC entity name (which will change from the
input if a related entity is found) and the ICAT field name
mapping/translation from the PaNOSC data model
:raises FilterError: If a valid mapping cannot be found
"""

try:
Expand Down
12 changes: 12 additions & 0 deletions datagateway_api/src/search_api/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging

from datagateway_api.src.datagateway_api.filter_order_handler import FilterOrderHandler
from datagateway_api.src.search_api.query import SearchAPIQuery
from datagateway_api.src.search_api.session_handler import (
client_manager,
SessionHandler,
Expand All @@ -13,6 +15,16 @@
# given to these functions
@client_manager
def get_search(endpoint_name, entity_name, filters=[]):
log.debug("Entity Name: %s, Filters: %s", entity_name, filters)

query = SearchAPIQuery(entity_name)

filter_handler = FilterOrderHandler()
filter_handler.add_filters(filters)
filter_handler.add_query_to_where_filters(query)
filter_handler.apply_filters(query)

log.debug("Python ICAT Query: %s", query.query.query)
# TODO - `getApiVersion()` used as a placeholder for testing client handling
# Replace with endpoint functionality when implementing the endpoints
return SessionHandler.client.getApiVersion()
Expand Down

0 comments on commit 82ae018

Please sign in to comment.