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):
|
def findMetadata(data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
key: string,
|
key: value,
|
||||||
value: string
|
|
||||||
}
|
}
|
||||||
returns {
|
returns {
|
||||||
items: [{
|
items: [{
|
||||||
|
@ -231,20 +230,21 @@ def findMetadata(data):
|
||||||
'items': []
|
'items': []
|
||||||
}
|
}
|
||||||
logger.debug('findMetadata %s', data)
|
logger.debug('findMetadata %s', data)
|
||||||
if data['key'] == 'isbn':
|
key = ','.join(sorted(data))
|
||||||
r = meta.lookup(data['key'], data['value'])
|
if key == 'isbn':
|
||||||
|
r = meta.lookup(key, data[key])
|
||||||
if r:
|
if r:
|
||||||
response['items'].append(r)
|
response['items'].append(r)
|
||||||
elif data['key'] == 'title':
|
elif key == 'author,title':
|
||||||
r = meta.find(data['value'])
|
value = ' '.join(data.values())
|
||||||
for isbn in meta.find(data['value']):
|
for isbn in meta.find(value):
|
||||||
r = meta.lookup('isbn', isbn)
|
r = meta.lookup('isbn', isbn)
|
||||||
if r:
|
if r:
|
||||||
response['items'].append(r)
|
response['items'].append(r)
|
||||||
elif data['key'] == 'id':
|
elif key == 'id':
|
||||||
import user.models
|
import user.models
|
||||||
items = {}
|
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:
|
if m.data_hash not in items:
|
||||||
items[m.data_hash] = m.data
|
items[m.data_hash] = m.data
|
||||||
items[m.data_hash]['users'] = [m.user_id]
|
items[m.data_hash]['users'] = [m.user_id]
|
||||||
|
|
Loading…
Reference in a new issue