Skip to contentSkip to conversation

Improvements to recipe search

PATCH In review Jose Lamego 1 participant 5 messages Jan 18, 2017 – Jan 24, 2017

lore
Share & tools
lore
#0 lore raw

cover Improvements to recipe search

These changes improve recipe searches in the OpenEmbedded Layer Index by allowing the layer name to be include as parameter to search and automatically redirecting to the recipe details view when a single result is yielded.

[YOCTO #6618]

Alex Franco (2):
views.py: Redirect to recipe details for single results views.py: Consider layer name in recipe search

 layerindex/views.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/2 views.py: Redirect to recipe details for single results

From: Alex Franco <[email protected]>

When a recipe search returns only one result, clicking the single result at the results view is still required to view further recipe detail.

This change automatically redirects to the recipe details view when the recipe search returns a single result.

[YOCTO #6618]

---
 layerindex/views.py | 8 ++++++++
 1 file changed, 8 insertions(+)
layerindex/views.py +8 -0
index 0f73e93..03fadbb 100644
@@ -372,6 +372,14 @@ class RecipeSearchView(ListView):
     context_object_name = 'recipe_list'
     paginate_by = 50
 
+    def render_to_response(self, context, **kwargs):
+        if len(self.object_list) == 1:
+            return HttpResponseRedirect("/layerindex/recipe/%s/"
+                                        % self.object_list[0].id)
+        else:
+            return super(ListView, self).render_to_response(context,
+                                                            **kwargs)
+
     def get_queryset(self):
         _check_url_branch(self.kwargs)
         query_string = self.request.GET.get('q', '')
Signature · 1 line
1.9.1
#2 lore raw

Re: [layerindex-web][PATCH 1/2] views.py: Redirect to recipe details for single results

ping

Quoted 36 lines · Jose Lamego

From: Alex Franco <[email protected]>

When a recipe search returns only one result, clicking the single result at the results view is still required to view further recipe detail.

This change automatically redirects to the recipe details view when the recipe search returns a single result.

[YOCTO #6618]

---
 layerindex/views.py | 8 ++++++++
 1 file changed, 8 insertions(+)
layerindex/views.py +8 -0
index 0f73e93..03fadbb 100644
@@ -372,6 +372,14 @@ class RecipeSearchView(ListView):
     context_object_name = 'recipe_list'
     paginate_by = 50
 
+    def render_to_response(self, context, **kwargs):
+        if len(self.object_list) == 1:
+            return HttpResponseRedirect("/layerindex/recipe/%s/"
+                                        % self.object_list[0].id)
+        else:
+            return super(ListView, self).render_to_response(context,
+                                                            **kwargs)
+
     def get_queryset(self):
         _check_url_branch(self.kwargs)
         query_string = self.request.GET.get('q', '')
Signature · 1 line
Jose Lamego | OTC Embedded Platforms & Tools | GDC
#3 lore raw

PATCH 2/2 views.py: Consider layer name in recipe search

In reply to Jose Lamego

From: Alex Franco <[email protected]>

Recipe search cannot be narrowed to a specific layer, producing unnecessary results.

This change allows including a layers name when searching for recipes to narrow the yielded results by adding a layer name to the simplesearch.getquery call in the recipe search view.

[YOCTO #6618]

---
 layerindex/views.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
layerindex/views.py +2 -1
index 03fadbb..5db6fbc 100644
@@ -406,7 +406,8 @@ class RecipeSearchView(ListView):
             qs0 = init_qs.filter(pn=query_string).order_by(*order_by)
             qs0 = recipes_preferred_count(qs0)
 
-            entry_query = simplesearch.get_query(query_string, ['pn'])
+            entry_query = simplesearch.get_query(
+                query_string, ['pn', 'layerbranch__layer__name'])
             qs1 = init_qs.filter(entry_query).order_by(*order_by)
             qs1 = recipes_preferred_count(qs1)
 
Signature · 1 line
1.9.1
#4 lore raw

Re: [layerindex-web][PATCH 2/2] views.py: Consider layer name in recipe search

ping

Quoted 31 lines · Jose Lamego

From: Alex Franco <[email protected]>

Recipe search cannot be narrowed to a specific layer, producing unnecessary results.

This change allows including a layers name when searching for recipes to narrow the yielded results by adding a layer name to the simplesearch.getquery call in the recipe search view.

[YOCTO #6618]

---
 layerindex/views.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
layerindex/views.py +2 -1
index 03fadbb..5db6fbc 100644
@@ -406,7 +406,8 @@ class RecipeSearchView(ListView):
             qs0 = init_qs.filter(pn=query_string).order_by(*order_by)
             qs0 = recipes_preferred_count(qs0)
 
-            entry_query = simplesearch.get_query(query_string, ['pn'])
+            entry_query = simplesearch.get_query(
+                query_string, ['pn', 'layerbranch__layer__name'])
             qs1 = init_qs.filter(entry_query).order_by(*order_by)
             qs1 = recipes_preferred_count(qs1)
 
Signature · 1 line
Jose Lamego | OTC Embedded Platforms & Tools | GDC