only decode ids for found positions
merge document.view.get_positions into item.utils.get_positions
add flag to decode id before looking up in ids
Followup to 09ebbc9cc6
This commit is contained in:
parent
3d95d7013a
commit
c7157d5001
12 changed files with 24 additions and 47 deletions
|
|
@ -165,33 +165,6 @@ def parse_query(data, user):
|
|||
return query
|
||||
|
||||
|
||||
def get_positions(qs, query_positions):
|
||||
'''
|
||||
qs: a QuerySet
|
||||
query_positions: a list of AZ ids
|
||||
|
||||
TODO: merge this with item.utils.get_positions. The win is to fetch
|
||||
only the integer IDs and convert the (smaller) set of query_positions to
|
||||
ints, rather than fetch all keys for everything in qs (expected to be many
|
||||
orders of magnitude larger), ignore most of it, and convert those ids to
|
||||
strings.
|
||||
|
||||
Returns:
|
||||
{
|
||||
i: index of i in qs
|
||||
for i in query_positions
|
||||
}
|
||||
'''
|
||||
ids = list(qs.values_list('id', flat=True))
|
||||
ret = {}
|
||||
for i in query_positions:
|
||||
try:
|
||||
ret[i] = ids.index(ox.fromAZ(i))
|
||||
except:
|
||||
pass
|
||||
return ret
|
||||
|
||||
|
||||
def findDocuments(request, data):
|
||||
'''
|
||||
Finds documents for a given query
|
||||
|
|
@ -225,7 +198,8 @@ def findDocuments(request, data):
|
|||
#FIXME: actually implement position requests
|
||||
response['data']['position'] = 0
|
||||
elif 'positions' in data:
|
||||
response['data']['positions'] = get_positions(qs, query['positions'])
|
||||
ids = list(qs.values_list('id', flat=True))
|
||||
response['data']['positions'] = utils.get_positions(ids, query['positions'], decode_id=True)
|
||||
else:
|
||||
r = qs.aggregate(
|
||||
Sum('size')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue