Improvements to recipe search
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
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
@@ -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
PATCH 2/2 views.py: Consider layer name in recipe search
In reply to Jose LamegoFrom: 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
@@ -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
Re: [layerindex-web][PATCH 1/2] views.py: Redirect to recipe details for single results
In reply to Jose Lamegoping
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]
Signed-off-by Jose Lamego <[email protected]>--- layerindex/views.py | 8 ++++++++ 1 file changed, 8 insertions(+)layerindex/views.py +8
-0@@ -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
Re: [layerindex-web][PATCH 2/2] views.py: Consider layer name in recipe search
In reply to Jose Lamegoping
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]
Signed-off-by Jose Lamego <[email protected]>--- layerindex/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)layerindex/views.py +2
-1@@ -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