Skip to content

Commit

Permalink
use kwargs.search_request_object instead of request.GET in search_fil…
Browse files Browse the repository at this point in the history
…ters, re #11578
  • Loading branch information
whatisgalen committed Oct 27, 2024
1 parent c4023c1 commit 0315aac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
18 changes: 10 additions & 8 deletions arches/app/search/components/paging_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@

class PagingFilter(BaseSearchFilter):
def append_dsl(self, search_query_object, **kwargs):
export = self.request.GET.get("export", None)
mobile_download = self.request.GET.get("mobiledownload", None)
search_request_object = kwargs.get("search_request_object", self.request.GET)
export = search_request_object.get("export", None)
mobile_download = search_request_object.get("mobiledownload", None)
page = (
1
if self.request.GET.get(self.componentname) == ""
else int(self.request.GET.get(self.componentname, 1))
if search_request_object.get(self.componentname) == ""
else int(search_request_object.get(self.componentname, 1))
)

if export is not None:
limit = settings.SEARCH_RESULT_LIMIT
elif mobile_download is not None:
limit = self.request.GET["resourcecount"]
limit = search_request_object.get("resourcecount")
else:
limit = settings.SEARCH_ITEMS_PER_PAGE
limit = int(self.request.GET.get("limit", limit))
limit = int(search_request_object.get("limit", limit))
search_query_object["query"].start = limit * int(page - 1)
search_query_object["query"].limit = limit

def post_search_hook(self, search_query_object, response_object, **kwargs):
search_request_object = kwargs.get("search_request_object", self.request.GET)
total = (
response_object["results"]["hits"]["total"]["value"]
if response_object["results"]["hits"]["total"]["value"]
Expand All @@ -44,8 +46,8 @@ def post_search_hook(self, search_query_object, response_object, **kwargs):
)
page = (
1
if self.request.GET.get(self.componentname) == ""
else int(self.request.GET.get(self.componentname, 1))
if search_request_object.get(self.componentname) == ""
else int(search_request_object.get(self.componentname, 1))
)

paginator, pages = get_paginator(
Expand Down
2 changes: 1 addition & 1 deletion arches/app/search/components/sort_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class SortResults(BaseSearchFilter):
def append_dsl(self, search_query_object, **kwargs):
sort_param = self.request.GET.get(self.componentname, None)
sort_param = kwargs.get("querystring", None)

if sort_param is not None and sort_param != "":
search_query_object["query"].sort(
Expand Down
3 changes: 2 additions & 1 deletion arches/app/search/components/term_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def append_dsl(self, search_query_object, **kwargs):
include_provisional = kwargs.get("include_provisional")
search_query = Bool()
querystring_params = kwargs.get("querystring", "[]")
language = self.request.GET.get("language", "*")
search_request_object = kwargs.get("search_request_object", self.request.GET)
language = search_request_object.get("language", "*")
for term in JSONDeserializer().deserialize(querystring_params):
if term["type"] == "term" or term["type"] == "string":
string_filter = Bool()
Expand Down

0 comments on commit 0315aac

Please sign in to comment.