autocomplete: group after join, use findvalue

This commit is contained in:
j 2016-01-12 13:47:15 +05:30
parent 527330521b
commit c85ec239a2

View file

@ -206,9 +206,9 @@ def autocomplete(data):
qs = qs.filter(models.Find.findvalue.startswith(value))
elif op == '$':
qs = qs.filter(models.Find.findvalue.endswith(value))
qs = qs.group_by(models.Find.value)
if add_itemsort:
qs = qs.join(models.Item).join(models.Sort)
qs = qs.group_by(models.Find.findvalue)
qs = qs.order_by(*order_by)
response['items'] = [r.value for r in qs[data['range'][0]:data['range'][1]]]
return response