mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
update q/a cache after bulk tag update
This commit is contained in:
parent
e1d3f791f5
commit
447985fc87
1 changed files with 15 additions and 0 deletions
15
anki/deck.py
15
anki/deck.py
|
@ -1121,6 +1121,19 @@ facts.modelId = :id""", id=model.id)
|
||||||
return
|
return
|
||||||
self.updateCardQACache(ids, dirty)
|
self.updateCardQACache(ids, dirty)
|
||||||
|
|
||||||
|
def updateCardQACacheFromCardIds(self, ids, type="cards"):
|
||||||
|
"Given a list of card or fact ids, update q/a cache."
|
||||||
|
if type == "cards":
|
||||||
|
col = "c.id"
|
||||||
|
else:
|
||||||
|
col = "f.id"
|
||||||
|
rows = self.s.all("""
|
||||||
|
select c.id, c.cardModelId, f.id, f.modelId
|
||||||
|
from cards as c, facts as f
|
||||||
|
where c.factId = f.id
|
||||||
|
and %s in %s""" % (col, ids2str(ids)))
|
||||||
|
self.updateCardQACache(rows)
|
||||||
|
|
||||||
def updateCardQACache(self, ids, dirty=True):
|
def updateCardQACache(self, ids, dirty=True):
|
||||||
"Given a list of (cardId, cardModelId, factId, modId), update q/a cache."
|
"Given a list of (cardId, cardModelId, factId, modId), update q/a cache."
|
||||||
if dirty:
|
if dirty:
|
||||||
|
@ -1220,6 +1233,7 @@ update %s set
|
||||||
tags = :tags,
|
tags = :tags,
|
||||||
modified = :now
|
modified = :now
|
||||||
where id = :id""" % table, pending)
|
where id = :id""" % table, pending)
|
||||||
|
self.updateCardQACacheFromCardIds([x[0] for x in tlist], type=table)
|
||||||
self.flushMod()
|
self.flushMod()
|
||||||
|
|
||||||
def addFactTags(self, ids, tags):
|
def addFactTags(self, ids, tags):
|
||||||
|
@ -1248,6 +1262,7 @@ update %s set
|
||||||
tags = :tags,
|
tags = :tags,
|
||||||
modified = :now
|
modified = :now
|
||||||
where id = :id""" % table, pending)
|
where id = :id""" % table, pending)
|
||||||
|
self.updateCardQACacheFromCardIds([x[0] for x in tlist], type=table)
|
||||||
self.flushMod()
|
self.flushMod()
|
||||||
|
|
||||||
def deleteFactTags(self, ids, tags):
|
def deleteFactTags(self, ids, tags):
|
||||||
|
|
Loading…
Reference in a new issue