tweak logging

- log only sched getCard(), not all getCard calls
- don't log sched.today unless it's changed
This commit is contained in:
Damien Elmes 2013-10-30 22:42:32 +09:00
parent 5f0ef85044
commit 3348b091d0
4 changed files with 9 additions and 8 deletions

View file

@ -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)

View file

@ -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):

View file

@ -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):

View file

@ -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):