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)
if flds != origFlds:
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:
return 0
# 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.genCards(nids)
return len(d)

View File

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

View File

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