From 26901367113c1cbc55986b9e17ad6fdafe9ffd8d Mon Sep 17 00:00:00 2001 From: d42 Date: Wed, 10 Oct 2018 20:37:30 +0200 Subject: [PATCH] undefecate prop query :^) --- storage/views.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/storage/views.py b/storage/views.py index b8e2a93..fd5a35d 100644 --- a/storage/views.py +++ b/storage/views.py @@ -121,10 +121,13 @@ class PropSelectView(AutoResponseView): # context = self.get_context_data() with connection.cursor() as c: c.execute(""" - select e from ( - select skeys(props) as e, count(skeys(props)) as e_count - from storage_item group by e order by e_count desc) as xD - where e like %s limit 10;""", ['%' + self.term + '%']) + SELECT key, count(*) FROM + (SELECT (each(props)).key FROM storage_item) AS stat + WHERE key like %s + GROUP BY key + ORDER BY count DESC, key + limit 10; + """, ['%' + self.term + '%']) props = [e[0] for e in c.fetchall()] return JsonResponse({ 'results': [