-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
11578 make search-filters request.method agnostic #11582
base: dev/7.6.x
Are you sure you want to change the base?
Changes from 5 commits
c4023c1
0315aac
6599a43
30e3dac
fa81b4f
a1f34c4
e68f68b
9f46aa9
9abbbba
3efea56
de2dd67
52a7b05
127d1d4
72289c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this be
|
||
|
||
if sort_param is not None and sort_param != "": | ||
search_query_object["query"].sort( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,7 @@ | |
class StandardSearchView(BaseSearchView): | ||
|
||
def append_dsl(self, search_query_object, **kwargs): | ||
search_request_object = kwargs.get("search_request_object", self.request.GET) | ||
search_query_object["query"].include("graph_id") | ||
search_query_object["query"].include("root_ontology_class") | ||
search_query_object["query"].include("resourceinstanceid") | ||
|
@@ -132,15 +133,16 @@ def append_dsl(self, search_query_object, **kwargs): | |
search_query_object["query"].include("map_popup") | ||
search_query_object["query"].include("provisional_resource") | ||
search_query_object["query"].include("permissions") | ||
load_tiles = get_str_kwarg_as_bool("tiles", self.request.GET) | ||
load_tiles = get_str_kwarg_as_bool("tiles", search_request_object) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for clarity, and to improve on something that should have been done in the first place, this should default to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This actually already does default to def get_str_kwarg_as_bool(
key, request_dict: Union[Dict[str, Any], QueryDict], default: bool = False
) -> bool:
value = request_dict.get(key, str(default))
if isinstance(value, bool):
return value
return str_to_bool(str(value)) |
||
if load_tiles: | ||
search_query_object["query"].include("tiles") | ||
|
||
def execute_query(self, search_query_object, response_object, **kwargs): | ||
for_export = get_str_kwarg_as_bool("export", self.request.GET) | ||
pages = self.request.GET.get("pages", None) | ||
total = int(self.request.GET.get("total", "0")) | ||
resourceinstanceid = self.request.GET.get("id", None) | ||
search_request_object = kwargs.get("search_request_object", self.request.GET) | ||
for_export = get_str_kwarg_as_bool("export", search_request_object) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above, should default to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see comment above |
||
pages = search_request_object.get("pages", None) | ||
total = int(search_request_object.get("total", "0")) | ||
resourceinstanceid = search_request_object.get("id", None) | ||
dsl = search_query_object["query"] | ||
if for_export or pages: | ||
results = dsl.search(index=RESOURCES_INDEX, scroll="1m") | ||
|
@@ -220,6 +222,7 @@ def handle_search_results_query( | |
permitted_nodegroups=permitted_nodegroups, | ||
include_provisional=include_provisional, | ||
querystring=querystring, | ||
search_request_object=sorted_query_obj, | ||
) | ||
append_instance_permission_filter_dsl(self.request, search_query_object) | ||
except Exception as err: | ||
|
@@ -235,7 +238,11 @@ def handle_search_results_query( | |
for filter_type, querystring in list(sorted_query_obj.items()): | ||
search_filter = search_filter_factory.get_filter(filter_type) | ||
if search_filter: | ||
search_filter.execute_query(search_query_object, response_object) | ||
search_filter.execute_query( | ||
search_query_object, | ||
response_object, | ||
search_request_object=sorted_query_obj, | ||
) | ||
|
||
if response_object["results"] is not None: | ||
# allow filters to modify the results | ||
|
@@ -246,6 +253,7 @@ def handle_search_results_query( | |
search_query_object, | ||
response_object, | ||
permitted_nodegroups=permitted_nodegroups, | ||
search_request_object=sorted_query_obj, | ||
) | ||
|
||
search_query_object.pop("query") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where did this number come from? 2048 seems like the most Edge can handle but most other browsers much more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This leaves a generous buffer in case the host is really long as can sometimes be the case with development hosts using Azure, for example: "https://longsubdomain.azure.cloudapp.westus3.developmentserverlongname." Is there a reason you think we should increase this limit + forego compatibility with Edge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe another option is to build the full GET URL string and compare that to the 2048 limit? May need to URL Encode the query string to as that can add a large number of characters to the URL (eg: " " -> "%20", etc).
Something like this might work to get the full URL length?:
Also - there's at least one other place that we'll need to handle this on the front end. Maybe worth wrapping the logic in a separate util function as it feels like this may be implemented in a number of places?
arches/arches/app/media/js/views/components/search/search-export.js
Lines 77 to 80 in debacb9