From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: yocto@yoctoproject.org
Subject: [layerindex-web][PATCH 2/2] views: ensure exact matches on name are shown first in recipe search
Date: Wed, 19 Oct 2016 16:56:35 +1300 [thread overview]
Message-ID: <1476849395-1580-2-git-send-email-paul.eggleton@linux.intel.com> (raw)
In-Reply-To: <1476849395-1580-1-git-send-email-paul.eggleton@linux.intel.com>
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.eggleton@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
prev parent reply other threads:[~2016-10-19 3:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-19 3:56 [layerindex-web][PATCH 1/2] views: ensure we only show results once in recipe search Paul Eggleton
2016-10-19 3:56 ` Paul Eggleton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1476849395-1580-2-git-send-email-paul.eggleton@linux.intel.com \
--to=paul.eggleton@linux.intel.com \
--cc=yocto@yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.