From 3348b091d0ee86f267302549a18b98114ffe497c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 30 Oct 2013 22:42:32 +0900 Subject: [PATCH] tweak logging - log only sched getCard(), not all getCard calls - don't log sched.today unless it's changed --- anki/collection.py | 7 ++----- anki/notes.py | 2 +- anki/sched.py | 6 +++++- aqt/browser.py | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/anki/collection.py b/anki/collection.py index 2af345bb9..4f9a92059 100644 --- a/anki/collection.py +++ b/anki/collection.py @@ -205,11 +205,8 @@ crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""", # Object creation helpers ########################################################################## - def getCard(self, id, log=True): - c = anki.cards.Card(self, id) - if log: - self.log(c, stack=1) - return c + def getCard(self, id): + return anki.cards.Card(self, id) def getNote(self, id): return anki.notes.Note(self, id=id) diff --git a/anki/notes.py b/anki/notes.py index d1f54a7b6..16be73e0a 100644 --- a/anki/notes.py +++ b/anki/notes.py @@ -69,7 +69,7 @@ insert or replace into notes values (?,?,?,?,?,?,?,?,?,?,?)""", return joinFields(self.fields) def cards(self): - return [self.col.getCard(id, log=False) for id in self.col.db.list( + return [self.col.getCard(id) for id in self.col.db.list( "select id from cards where nid = ? order by ord", self.id)] def model(self): diff --git a/anki/sched.py b/anki/sched.py index 505ab47bb..12cd092ea 100644 --- a/anki/sched.py +++ b/anki/sched.py @@ -30,6 +30,7 @@ class Scheduler(object): self.queueLimit = 50 self.reportLimit = 1000 self.reps = 0 + self.today = None self._haveQueues = False self._updateCutoff() @@ -40,6 +41,7 @@ class Scheduler(object): self.reset() card = self._getCard() if card: + self.col.log(card) if not self._burySiblingsOnAnswer: self._burySiblings(card) self.reps += 1 @@ -1118,11 +1120,13 @@ did = ?, queue = %s, due = ?, mod = ?, usn = ? where id = ?""" % queue, data) ########################################################################## def _updateCutoff(self): + oldToday = self.today # days since col created self.today = int((time.time() - self.col.crt) // 86400) # end of day cutoff self.dayCutoff = self.col.crt + (self.today+1)*86400 - self.col.log(self.today, self.dayCutoff) + if oldToday != self.today: + self.col.log(self.today, self.dayCutoff) # update all daily counts, but don't save decks to prevent needless # conflicts. we'll save on card answer instead def update(g): diff --git a/aqt/browser.py b/aqt/browser.py index defe4fce9..91c4b5644 100644 --- a/aqt/browser.py +++ b/aqt/browser.py @@ -45,7 +45,7 @@ class DataModel(QAbstractTableModel): def getCard(self, index): id = self.cards[index.row()] if not id in self.cardObjs: - self.cardObjs[id] = self.col.getCard(id, log=False) + self.cardObjs[id] = self.col.getCard(id) return self.cardObjs[id] def refreshNote(self, note):