dont reuse same variable in loop
This commit is contained in:
parent
fba3f46787
commit
314bb863eb
1 changed files with 7 additions and 6 deletions
|
@ -247,17 +247,18 @@ def findMetadata(data):
|
||||||
elif key == 'id':
|
elif key == 'id':
|
||||||
import user.models
|
import user.models
|
||||||
items = {}
|
items = {}
|
||||||
|
value = data[key]
|
||||||
for u in user.models.User.query.filter_by(peered=True):
|
for u in user.models.User.query.filter_by(peered=True):
|
||||||
peer = utils.get_peer(u.id)
|
peer = utils.get_peer(u.id)
|
||||||
if data[key] in peer.library:
|
if value in peer.library:
|
||||||
h = peer.get_metahash(data[key])
|
h = peer.get_metahash(value)
|
||||||
if h not in items:
|
if h not in items:
|
||||||
items[h] = peer.library[data[key]].get('meta', {}).copy()
|
items[h] = peer.library[value].get('meta', {}).copy()
|
||||||
items[h]['users'] = [u.id]
|
items[h]['users'] = [u.id]
|
||||||
j = items[h]
|
j = items[h]
|
||||||
for key in [k['id'] for k in settings.config['itemKeys'] if isinstance(k['type'], list)]:
|
for key_ in [k['id'] for k in settings.config['itemKeys'] if isinstance(k['type'], list)]:
|
||||||
if key in j and not isinstance(j[key], list):
|
if key_ in j and not isinstance(j[key_], list):
|
||||||
j[key] = [j[key]] if j[key] else []
|
j[key_] = [j[key_]] if j[key_] else []
|
||||||
else:
|
else:
|
||||||
items[h]['users'].append(u.id)
|
items[h]['users'].append(u.id)
|
||||||
response['items'] = list(items.values())
|
response['items'] = list(items.values())
|
||||||
|
|
Loading…
Reference in a new issue