Skip to content

Commit

Permalink
refactor: refactor implementation of SearchAPIScoringFilter #398
Browse files Browse the repository at this point in the history
  • Loading branch information
VKTB committed Feb 10, 2023
1 parent 0a3c166 commit 9277dd3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
7 changes: 0 additions & 7 deletions datagateway_api/src/common/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,3 @@ class IncludeFilter(QueryFilter):

def __init__(self, included_filters):
self.included_filters = included_filters


class ScoringQueryFilter(QueryFilter):
precedence = 6

def __init__(self, value):
self.value = value
10 changes: 6 additions & 4 deletions datagateway_api/src/search_api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import logging

from datagateway_api.src.common.date_handler import DateHandler
from datagateway_api.src.common.filters import ScoringQueryFilter
from datagateway_api.src.datagateway_api.icat.filters import (
PythonICATIncludeFilter,
PythonICATLimitFilter,
Expand Down Expand Up @@ -163,12 +162,15 @@ def apply_filter(self, query):
return super().apply_filter(query.icat_query.query)


class SearchAPIScoringFilter(ScoringQueryFilter):
class SearchAPIScoringFilter(SearchAPIWhereFilter):
def __init__(self, query_value):
super().__init__(query_value)
# We are only supporting scoring on the Document entity/ endpoint so hard
# coding the corresponding field (summary) here that is used when searching for
# documents that match the query_value pattern.
super().__init__(field="summary", value=query_value, operation="ilike")

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


class SearchAPIIncludeFilter(PythonICATIncludeFilter):
Expand Down

0 comments on commit 9277dd3

Please sign in to comment.