update findMetadata api
This commit is contained in:
parent
bc3aac80fa
commit
cf74e622be
1 changed files with 9 additions and 9 deletions
|
@ -217,8 +217,7 @@ actions.register(autocomplete)
|
|||
def findMetadata(data):
|
||||
'''
|
||||
takes {
|
||||
key: string,
|
||||
value: string
|
||||
key: value,
|
||||
}
|
||||
returns {
|
||||
items: [{
|
||||
|
@ -231,20 +230,21 @@ def findMetadata(data):
|
|||
'items': []
|
||||
}
|
||||
logger.debug('findMetadata %s', data)
|
||||
if data['key'] == 'isbn':
|
||||
r = meta.lookup(data['key'], data['value'])
|
||||
key = ','.join(sorted(data))
|
||||
if key == 'isbn':
|
||||
r = meta.lookup(key, data[key])
|
||||
if r:
|
||||
response['items'].append(r)
|
||||
elif data['key'] == 'title':
|
||||
r = meta.find(data['value'])
|
||||
for isbn in meta.find(data['value']):
|
||||
elif key == 'author,title':
|
||||
value = ' '.join(data.values())
|
||||
for isbn in meta.find(value):
|
||||
r = meta.lookup('isbn', isbn)
|
||||
if r:
|
||||
response['items'].append(r)
|
||||
elif data['key'] == 'id':
|
||||
elif key == 'id':
|
||||
import user.models
|
||||
items = {}
|
||||
for m in user.models.Metadata.query.filter_by(item_id=data['value']):
|
||||
for m in user.models.Metadata.query.filter_by(item_id=data[key]):
|
||||
if m.data_hash not in items:
|
||||
items[m.data_hash] = m.data
|
||||
items[m.data_hash]['users'] = [m.user_id]
|
||||
|
|
Loading…
Reference in a new issue