summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2014-10-18 18:28:26 -0500
committerDan McGee <dan@archlinux.org>2014-10-18 18:28:26 -0500
commit061805aa73d3d5b418a61fa6d6591d1a7d03d9ed (patch)
treeb7cd8cca5eba3c358a000b399cc2cd756b88b6a1 /packages
parent4def86ec76d9975be8a357b6fc06104cc2b31fed (diff)
FS#30773: put exact matches at top
There have been a few proposed solutions to this, but there really isn't anything without a drawback. Things break pagination, require loading the entire result set from the database, etc. Just plop a new table on the page if someone did a so-called "simple" search and we have a match. Only show on the first page of the search results. This results in a relatively fast experience for someone doing something like searching for the "perl" package. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages')
-rw-r--r--packages/views/search.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/packages/views/search.py b/packages/views/search.py
index b3778172..0b776d79 100644
--- a/packages/views/search.py
+++ b/packages/views/search.py
@@ -45,6 +45,12 @@ class PackageSearchForm(forms.Form):
[('', 'All'), ('unknown', 'Unknown')] + \
[(m.username, m.get_full_name()) for m in maints]
+ def exact_matches(self):
+ # only do exact match search if 'q' is sole parameter
+ if self.changed_data != ['q']:
+ return []
+ return Package.objects.normal().filter(pkgname=self.cleaned_data['q'])
+
def parse_form(form, packages):
if form.cleaned_data['repo']: