Improves slightly on 3155206e54413f72df3b3b41280eafd332a58ba4 by doing
an exact match on name and showing that first - now when you search for
"git" you really do get the git recipe first in the list.

Signed-off-by: Paul Eggleton <paul.eggle...@linux.intel.com>
---
 layerindex/views.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/layerindex/views.py b/layerindex/views.py
index 3e78c58..7045a12 100644
--- a/layerindex/views.py
+++ b/layerindex/views.py
@@ -378,6 +378,9 @@ class RecipeSearchView(ListView):
         if query_string.strip():
             order_by = ('pn', 'layerbranch__layer')
 
+            qs0 = init_qs.filter(pn=query_string).order_by(*order_by)
+            qs0 = recipes_preferred_count(qs0)
+
             entry_query = simplesearch.get_query(query_string, ['pn'])
             qs1 = init_qs.filter(entry_query).order_by(*order_by)
             qs1 = recipes_preferred_count(qs1)
@@ -386,7 +389,7 @@ class RecipeSearchView(ListView):
             qs2 = init_qs.filter(entry_query).order_by(*order_by)
             qs2 = recipes_preferred_count(qs2)
 
-            qs = list(utils.chain_unique(qs1, qs2))
+            qs = list(utils.chain_unique(qs0, qs1, qs2))
         else:
             if 'q' in self.request.GET:
                 qs = init_qs.order_by('pn', 'layerbranch__layer')
@@ -732,13 +735,15 @@ class ClassicRecipeSearchView(RecipeSearchView):
         if query_string.strip():
             order_by = ('pn', 'layerbranch__layer')
 
+            qs0 = init_qs.filter(pn==query_string).order_by(*order_by)
+
             entry_query = simplesearch.get_query(query_string, ['pn'])
             qs1 = init_qs.filter(entry_query).order_by(*order_by)
 
             entry_query = simplesearch.get_query(query_string, ['summary', 
'description'])
             qs2 = init_qs.filter(entry_query).order_by(*order_by)
 
-            qs = list(utils.chain_unique(qs1, qs2))
+            qs = list(utils.chain_unique(qs0, qs1, qs2))
         else:
             if 'q' in self.request.GET:
                 qs = init_qs.order_by('pn', 'layerbranch__layer')
-- 
2.5.5

-- 
_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto

Reply via email to