Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Clean querysets

Jakub Draganek970a49a06bd4
diff --git a/saleor/search/backends/elasticsearch.py b/saleor/search/backends/elasticsearch.py
index 7763229614..ddf0c4acb2 100644
--- a/saleor/search/backends/elasticsearch.py
+++ b/saleor/search/backends/elasticsearch.py
@@ -13,5 +13,5 @@ def get_search_query(phrase):
.filter('term', is_published=True))
-def search(phrase, qs):
- return qs & get_search_query(phrase).to_queryset()
+def search(phrase):
+ return get_search_query(phrase).to_queryset()
diff --git a/saleor/search/forms.py b/saleor/search/forms.py
index 28c401271f..65bf35c803 100644
--- a/saleor/search/forms.py
+++ b/saleor/search/forms.py
@@ -7,5 +7,5 @@ class SearchForm(forms.Form):
q = forms.CharField(
label=pgettext('Search form label', 'Query'), required=True)
- def search(self, qs):
- return elasticsearch.search(self.cleaned_data['q'], qs)
+ def search(self):
+ return elasticsearch.search(self.cleaned_data['q'])
diff --git a/saleor/search/views.py b/saleor/search/views.py
index 6bb1edd1c9..05d4a8d8cb 100644
--- a/saleor/search/views.py
+++ b/saleor/search/views.py
@@ -20,8 +20,7 @@ def paginate_results(results, get_data, paginate_by=settings.PAGINATE_BY):
def evaluate_search_query(form, request):
query = form.cleaned_data.get('q', '')
- visible_products = products_with_details(request.user)
- results = form.search(qs=visible_products)
+ results = products_with_details(request.user) & form.search()
results = products_with_availability(
results,
discounts=request.discounts,