rebuild due counts after sync

This commit is contained in:
Damien Elmes 2008-11-16 04:20:14 +09:00
parent 76e3659832
commit 26ad7e8149
2 changed files with 8 additions and 3 deletions

View file

@ -432,10 +432,11 @@ then 1 -- review
else 2 -- new else 2 -- new
end)""" + where) end)""" + where)
def rebuildCounts(self): def rebuildCounts(self, full=True):
# need to check due first, so new due cards are not added later # need to check due first, so new due cards are not added later
self.checkDue() self.checkDue()
# global counts # global counts
if full:
self.cardCount = self.s.scalar("select count(*) from cards") self.cardCount = self.s.scalar("select count(*) from cards")
self.factCount = self.s.scalar("select count(*) from facts") self.factCount = self.s.scalar("select count(*) from facts")
# due counts # due counts

View file

@ -132,6 +132,8 @@ class SyncTools(object):
# rebuild priorities on server # rebuild priorities on server
cardIds = [x[0] for x in payload['added-cards']] cardIds = [x[0] for x in payload['added-cards']]
self.rebuildPriorities(cardIds, self.serverExcludedTags) self.rebuildPriorities(cardIds, self.serverExcludedTags)
# rebuild due counts
self.deck.rebuildCounts(full=False)
return reply return reply
def applyPayloadReply(self, reply): def applyPayloadReply(self, reply):
@ -149,6 +151,8 @@ class SyncTools(object):
# rebuild priorities on client # rebuild priorities on client
cardIds = [x[0] for x in reply['added-cards']] cardIds = [x[0] for x in reply['added-cards']]
self.rebuildPriorities(cardIds) self.rebuildPriorities(cardIds)
# rebuild due counts
self.deck.rebuildCounts(full=False)
def rebuildPriorities(self, cardIds, extraExcludes=[]): def rebuildPriorities(self, cardIds, extraExcludes=[]):
where = "and cards.id in %s" % ids2str(cardIds) where = "and cards.id in %s" % ids2str(cardIds)