mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 12:49:01 +02:00
views: ensure exact matches on name are shown first in recipe search
Improves slightly on 3155206e54
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.eggleton@linux.intel.com>
This commit is contained in:
parent
c6105d69cf
commit
e6a3008c7e
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue
Block a user