From 26ad7e81495db31e4bb74c6510518e360a35a1eb Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 16 Nov 2008 04:20:14 +0900 Subject: [PATCH] rebuild due counts after sync --- anki/deck.py | 7 ++++--- anki/sync.py | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/anki/deck.py b/anki/deck.py index ac3ecc6aa..b3ada45d8 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -432,12 +432,13 @@ then 1 -- review else 2 -- new end)""" + where) - def rebuildCounts(self): + def rebuildCounts(self, full=True): # need to check due first, so new due cards are not added later self.checkDue() # global counts - self.cardCount = self.s.scalar("select count(*) from cards") - self.factCount = self.s.scalar("select count(*) from facts") + if full: + self.cardCount = self.s.scalar("select count(*) from cards") + self.factCount = self.s.scalar("select count(*) from facts") # due counts self.failedNowCount = self.s.scalar( "select count(*) from failedCardsNow") diff --git a/anki/sync.py b/anki/sync.py index cfa8abe66..cde42cb8d 100644 --- a/anki/sync.py +++ b/anki/sync.py @@ -132,6 +132,8 @@ class SyncTools(object): # rebuild priorities on server cardIds = [x[0] for x in payload['added-cards']] self.rebuildPriorities(cardIds, self.serverExcludedTags) + # rebuild due counts + self.deck.rebuildCounts(full=False) return reply def applyPayloadReply(self, reply): @@ -149,6 +151,8 @@ class SyncTools(object): # rebuild priorities on client cardIds = [x[0] for x in reply['added-cards']] self.rebuildPriorities(cardIds) + # rebuild due counts + self.deck.rebuildCounts(full=False) def rebuildPriorities(self, cardIds, extraExcludes=[]): where = "and cards.id in %s" % ids2str(cardIds)