better default limit in search hint
authorJan Szejko <janek37@gmail.com>
Fri, 15 Dec 2017 09:43:22 +0000 (10:43 +0100)
committerJan Szejko <janek37@gmail.com>
Fri, 15 Dec 2017 09:43:22 +0000 (10:43 +0100)
src/search/views.py

index b0f0641..8542e51 100644 (file)
@@ -71,10 +71,10 @@ def hint(request):
     try:
         limit = int(request.GET.get('max', ''))
     except ValueError:
-        limit = -1
+        limit = 20
     else:
         if limit < 1:
-            limit = -1
+            limit = 20
 
     data = [
         {
@@ -83,7 +83,7 @@ def hint(request):
             'id': author.id,
             'url': author.get_absolute_url(),
         }
-        for author in Tag.objects.filter(category='author', name__iregex=u'\m' + prefix)[:10]
+        for author in Tag.objects.filter(category='author', name__iregex=u'\m' + prefix)[:limit]
     ]
     if len(data) < limit:
         data += [