When searching on mappings we can surely set limit=1 to make the operation faster.

This commit is contained in:
Albert Cervera i Areny 2015-06-22 00:18:35 +02:00
parent 5788ecec35
commit b08089c016
1 changed files with 3 additions and 3 deletions

View File

@ -685,7 +685,7 @@ class Asset:
('local_id', '=', value),
('model', '=', mappings[name]),
('peer', '=', peer),
])
], limit=1)
assert db_mappings, ('No mappings found with local_id=%s, '
'model=%s, peer=%s' % (value, mappings[name], peer))
value = db_mappings[0].remote_id
@ -718,7 +718,7 @@ class Asset:
('remote_id', '=', value),
('model', '=', mappings[name]),
('peer', '=', peer),
])
], limit=1)
assert db_mappings, ('No mappings found with remote_id=%s, '
'model=%s, peer=%s' % (value, mappings[name], peer))
value = db_mappings[0].local_id
@ -741,7 +741,7 @@ class Asset:
('remote_id', '=', record['id']),
('peer', '=', peer),
('model', '=', cls.__name__),
])
], limit=1)
if maps:
local_ids.append(maps[0].local_id)
continue