remove remaining db kwargs

This commit is contained in:
Damien Elmes 2020-03-04 10:03:57 +10:00
parent 874ee80a68
commit 818401e464
3 changed files with 11 additions and 32 deletions

View File

@ -555,11 +555,11 @@ def findReplace(
flds = joinFields(sflds) flds = joinFields(sflds)
if flds != origFlds: if flds != origFlds:
nids.append(nid) nids.append(nid)
d.append(dict(nid=nid, flds=flds, u=col.usn(), m=intTime())) d.append((flds, intTime(), col.usn(), nid))
if not d: if not d:
return 0 return 0
# replace # replace
col.db.executemany("update notes set flds=:flds,mod=:m,usn=:u where id=:nid", d) col.db.executemany("update notes set flds=?,mod=?,usn=? where id=?", d)
col.updateFieldCache(nids) col.updateFieldCache(nids)
col.genCards(nids) col.genCards(nids)
return len(d) return len(d)

View File

@ -504,17 +504,9 @@ select id from notes where mid = ?)"""
for c in range(nfields): for c in range(nfields):
flds.append(newflds.get(c, "")) flds.append(newflds.get(c, ""))
flds = joinFields(flds) flds = joinFields(flds)
d.append( d.append((flds, newModel["id"], intTime(), self.col.usn(), nid,))
dict(
nid=nid,
flds=flds,
mid=newModel["id"],
m=intTime(),
u=self.col.usn(),
)
)
self.col.db.executemany( self.col.db.executemany(
"update notes set flds=:flds,mid=:mid,mod=:m,usn=:u where id = :nid", d "update notes set flds=?,mid=?,mod=?,usn=? where id = ?", d
) )
self.col.updateFieldCache(nids) self.col.updateFieldCache(nids)
@ -543,12 +535,10 @@ select id from notes where mid = ?)"""
# mapping from a regular note, so the map should be valid # mapping from a regular note, so the map should be valid
new = map[ord] new = map[ord]
if new is not None: if new is not None:
d.append(dict(cid=cid, new=new, u=self.col.usn(), m=intTime())) d.append((new, self.col.usn(), intTime(), cid))
else: else:
deleted.append(cid) deleted.append(cid)
self.col.db.executemany( self.col.db.executemany("update cards set ord=?,usn=?,mod=? where id=?", d)
"update cards set ord=:new,usn=:u,mod=:m where id=:cid", d
)
self.col.remCards(deleted) self.col.remCards(deleted)
# Schema hash # Schema hash

View File

@ -1775,21 +1775,12 @@ and (queue={QUEUE_TYPE_NEW} or (queue={QUEUE_TYPE_REV} and due<=?))""",
mod = intTime() mod = intTime()
for id in ids: for id in ids:
r = random.randint(imin, imax) r = random.randint(imin, imax)
d.append( d.append((max(1, r), r + t, self.col.usn(), mod, STARTING_FACTOR, id,))
dict(
id=id,
due=r + t,
ivl=max(1, r),
mod=mod,
usn=self.col.usn(),
fact=STARTING_FACTOR,
)
)
self.remFromDyn(ids) self.remFromDyn(ids)
self.col.db.executemany( self.col.db.executemany(
f""" f"""
update cards set type={CARD_TYPE_REV},queue={QUEUE_TYPE_REV},ivl=:ivl,due=:due,odue=0, update cards set type={CARD_TYPE_REV},queue={QUEUE_TYPE_REV},ivl=?,due=?,odue=0,
usn=:usn,mod=:mod,factor=:fact where id=:id""", usn=?,mod=?,factor=? where id=?""",
d, d,
) )
self.col.log(ids) self.col.log(ids)
@ -1866,10 +1857,8 @@ and due >= ? and queue = {QUEUE_TYPE_NEW}"""
for id, nid in self.col.db.execute( for id, nid in self.col.db.execute(
f"select id, nid from cards where type = {CARD_TYPE_NEW} and id in " + scids f"select id, nid from cards where type = {CARD_TYPE_NEW} and id in " + scids
): ):
d.append(dict(now=now, due=due[nid], usn=self.col.usn(), cid=id)) d.append((due[nid], now, self.col.usn(), id))
self.col.db.executemany( self.col.db.executemany("update cards set due=?,mod=?,usn=? where id = ?", d)
"update cards set due=:due,mod=:now,usn=:usn where id = :cid", d
)
def randomizeCards(self, did: int) -> None: def randomizeCards(self, did: int) -> None:
cids = self.col.db.list("select id from cards where did = ?", did) cids = self.col.db.list("select id from cards where did = ?", did)