moveTemplate slightly quicker

When a template is moved, only move the ord of cards whose position
did change.
This commit is contained in:
Arthur-Milchior 2019-01-20 15:40:23 +01:00
parent 2a539cda1b
commit b29fd508c7

View File

@ -397,7 +397,10 @@ update cards set ord = ord - 1, usn = ?, mod = ?
# generate change map
map = []
for t in m['tmpls']:
map.append("when ord = %d then %d" % (oldidxs[id(t)], t['ord']))
oldidx = oldidxs[id(t)]
newidx = t['ord']
if oldidx != newidx:
map.append("when ord = %d then %d" % (oldidx, newidx))
# apply
self.save(m)
self.col.db.execute("""