mirror of
https://github.com/ankitects/anki.git
synced 2025-11-11 15:17:12 -05:00
add progress to export, speed up export, tweak undo progress
This commit is contained in:
parent
87fbd896fc
commit
6015dbec04
2 changed files with 15 additions and 4 deletions
|
|
@ -1868,11 +1868,12 @@ insert into undoLog values (null, 'insert into %(t)s (rowid""" % {'t': table}
|
||||||
(start, end) = (u[1], u[2])
|
(start, end) = (u[1], u[2])
|
||||||
if end is None:
|
if end is None:
|
||||||
end = self._latestUndoRow()
|
end = self._latestUndoRow()
|
||||||
self.startProgress(_("Undo/Redo"), 0, 22)
|
|
||||||
sql = self.s.column0("""
|
sql = self.s.column0("""
|
||||||
select sql from undoLog where
|
select sql from undoLog where
|
||||||
seq > :s and seq <= :e order by seq desc""", s=start, e=end)
|
seq > :s and seq <= :e order by seq desc""", s=start, e=end)
|
||||||
mod = len(sql) / 20
|
mod = len(sql) / 20
|
||||||
|
if mod:
|
||||||
|
self.startProgress(_("Undo/Redo"), 0, 21)
|
||||||
self.updateProgress(_("Applying changes..."))
|
self.updateProgress(_("Applying changes..."))
|
||||||
newstart = self._latestUndoRow()
|
newstart = self._latestUndoRow()
|
||||||
for c, s in enumerate(sql):
|
for c, s in enumerate(sql):
|
||||||
|
|
@ -1882,6 +1883,7 @@ seq > :s and seq <= :e order by seq desc""", s=start, e=end)
|
||||||
self.engine.execute(s)
|
self.engine.execute(s)
|
||||||
newend = self._latestUndoRow()
|
newend = self._latestUndoRow()
|
||||||
dst.append([u[0], newstart, newend])
|
dst.append([u[0], newstart, newend])
|
||||||
|
if mod:
|
||||||
self.finishProgress()
|
self.finishProgress()
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,11 @@ class AnkiExporter(Exporter):
|
||||||
self.includeSchedulingInfo = False
|
self.includeSchedulingInfo = False
|
||||||
|
|
||||||
def exportInto(self, path):
|
def exportInto(self, path):
|
||||||
|
n = 4
|
||||||
|
if not self.includeSchedulingInfo:
|
||||||
|
n += 1
|
||||||
|
self.deck.startProgress(_("Export"), 0, n)
|
||||||
|
self.deck.updateProgress(_("Determining items..."))
|
||||||
self.newDeck = DeckStorage.Deck(path)
|
self.newDeck = DeckStorage.Deck(path)
|
||||||
client = SyncClient(self.deck)
|
client = SyncClient(self.deck)
|
||||||
server = SyncServer(self.newDeck)
|
server = SyncServer(self.newDeck)
|
||||||
|
|
@ -69,10 +74,12 @@ class AnkiExporter(Exporter):
|
||||||
# set up a custom change list and sync
|
# set up a custom change list and sync
|
||||||
lsum = self.localSummary()
|
lsum = self.localSummary()
|
||||||
rsum = server.summary(0)
|
rsum = server.summary(0)
|
||||||
|
self.deck.updateProgress(_("Copying..."))
|
||||||
payload = client.genPayload((lsum, rsum))
|
payload = client.genPayload((lsum, rsum))
|
||||||
|
self.deck.updateProgress(_("Applying..."))
|
||||||
res = server.applyPayload(payload)
|
res = server.applyPayload(payload)
|
||||||
client.applyPayloadReply(res)
|
|
||||||
if not self.includeSchedulingInfo:
|
if not self.includeSchedulingInfo:
|
||||||
|
self.deck.updateProgress(_("Updating schedule..."))
|
||||||
self.newDeck.s.statement("""
|
self.newDeck.s.statement("""
|
||||||
delete from reviewHistory""")
|
delete from reviewHistory""")
|
||||||
self.newDeck.s.statement("""
|
self.newDeck.s.statement("""
|
||||||
|
|
@ -114,10 +121,12 @@ delete from stats""")
|
||||||
bulkClient.server = bulkServer
|
bulkClient.server = bulkServer
|
||||||
bulkClient.sync()
|
bulkClient.sync()
|
||||||
# need to save manually
|
# need to save manually
|
||||||
|
self.deck.updateProgress(_("Finalizing..."))
|
||||||
self.newDeck.rebuildCounts()
|
self.newDeck.rebuildCounts()
|
||||||
self.exportedCards = self.newDeck.cardCount
|
self.exportedCards = self.newDeck.cardCount
|
||||||
self.newDeck.s.commit()
|
self.newDeck.s.commit()
|
||||||
self.newDeck.close()
|
self.newDeck.close()
|
||||||
|
self.deck.finishProgress()
|
||||||
|
|
||||||
def localSummary(self):
|
def localSummary(self):
|
||||||
cardIds = self.cardIds()
|
cardIds = self.cardIds()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue