mirror of
https://github.com/ankitects/anki.git
synced 2025-11-08 21:57:12 -05:00
trigger the db progress handler after more operations
We originally were triggering on 100 opcodes, because at the time we were doing write-heavy alterations to the DB for inactive tags, and a higher level of opcodes would pause the interface for a long time. The query structure is different now, so we can afford to save the overhead of more frequent calls. With the change, a .reset() triggers the handler 3 times; fixIntegrity() triggers it 30 times over a period of 4.5 seconds.
This commit is contained in:
parent
1dc3a0ad4a
commit
f74d9b68fe
2 changed files with 6 additions and 11 deletions
|
|
@ -71,3 +71,6 @@ class DB(object):
|
|||
|
||||
def close(self):
|
||||
self._db.close()
|
||||
|
||||
def set_progress_handler(self, *args):
|
||||
self._db.set_progress_handler(*args)
|
||||
|
|
|
|||
14
anki/deck.py
14
anki/deck.py
|
|
@ -535,12 +535,6 @@ where c.fid == f.id and f.mid == m.id and c.gid = g.id
|
|||
def tagList(self):
|
||||
return self.db.list("select name from tags order by name")
|
||||
|
||||
def cardsWithNoTags(self):
|
||||
return self.db.list("""
|
||||
select cards.id from cards, facts where
|
||||
facts.tags = ""
|
||||
and cards.fid = facts.id""")
|
||||
|
||||
def cardHasTag(self, card, tag):
|
||||
tags = self.db.scalar("select tags from fact where id = :fid",
|
||||
fid=card.fid)
|
||||
|
|
@ -630,16 +624,14 @@ update facts set tags = :t, mod = :n where id = :id""", [fix(row) for row in res
|
|||
return
|
||||
self.progressHandlerCalled = time.time()
|
||||
if self.progressHandlerEnabled:
|
||||
# things which hook on this should be very careful not to touch
|
||||
# the db as they run
|
||||
runHook("dbProgress")
|
||||
|
||||
def setupProgressHandler(self):
|
||||
self.progressHandlerCalled = 0
|
||||
self.progressHandlerEnabled = False
|
||||
try:
|
||||
self.engine.raw_connection().set_progress_handler(
|
||||
deck.progressHandler, 100)
|
||||
except:
|
||||
pass
|
||||
self.db.set_progress_handler(self.progressHandler, 100000)
|
||||
|
||||
def enableProgressHandler(self):
|
||||
self.progressHandlerEnabled = True
|
||||
|
|
|
|||
Loading…
Reference in a new issue