mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
tweak logging
- log only sched getCard(), not all getCard calls - don't log sched.today unless it's changed
This commit is contained in:
parent
5f0ef85044
commit
3348b091d0
4 changed files with 9 additions and 8 deletions
|
@ -205,11 +205,8 @@ crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""",
|
||||||
# Object creation helpers
|
# Object creation helpers
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
def getCard(self, id, log=True):
|
def getCard(self, id):
|
||||||
c = anki.cards.Card(self, id)
|
return anki.cards.Card(self, id)
|
||||||
if log:
|
|
||||||
self.log(c, stack=1)
|
|
||||||
return c
|
|
||||||
|
|
||||||
def getNote(self, id):
|
def getNote(self, id):
|
||||||
return anki.notes.Note(self, id=id)
|
return anki.notes.Note(self, id=id)
|
||||||
|
|
|
@ -69,7 +69,7 @@ insert or replace into notes values (?,?,?,?,?,?,?,?,?,?,?)""",
|
||||||
return joinFields(self.fields)
|
return joinFields(self.fields)
|
||||||
|
|
||||||
def cards(self):
|
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)]
|
"select id from cards where nid = ? order by ord", self.id)]
|
||||||
|
|
||||||
def model(self):
|
def model(self):
|
||||||
|
|
|
@ -30,6 +30,7 @@ class Scheduler(object):
|
||||||
self.queueLimit = 50
|
self.queueLimit = 50
|
||||||
self.reportLimit = 1000
|
self.reportLimit = 1000
|
||||||
self.reps = 0
|
self.reps = 0
|
||||||
|
self.today = None
|
||||||
self._haveQueues = False
|
self._haveQueues = False
|
||||||
self._updateCutoff()
|
self._updateCutoff()
|
||||||
|
|
||||||
|
@ -40,6 +41,7 @@ class Scheduler(object):
|
||||||
self.reset()
|
self.reset()
|
||||||
card = self._getCard()
|
card = self._getCard()
|
||||||
if card:
|
if card:
|
||||||
|
self.col.log(card)
|
||||||
if not self._burySiblingsOnAnswer:
|
if not self._burySiblingsOnAnswer:
|
||||||
self._burySiblings(card)
|
self._burySiblings(card)
|
||||||
self.reps += 1
|
self.reps += 1
|
||||||
|
@ -1118,10 +1120,12 @@ did = ?, queue = %s, due = ?, mod = ?, usn = ? where id = ?""" % queue, data)
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
def _updateCutoff(self):
|
def _updateCutoff(self):
|
||||||
|
oldToday = self.today
|
||||||
# days since col created
|
# days since col created
|
||||||
self.today = int((time.time() - self.col.crt) // 86400)
|
self.today = int((time.time() - self.col.crt) // 86400)
|
||||||
# end of day cutoff
|
# end of day cutoff
|
||||||
self.dayCutoff = self.col.crt + (self.today+1)*86400
|
self.dayCutoff = self.col.crt + (self.today+1)*86400
|
||||||
|
if oldToday != self.today:
|
||||||
self.col.log(self.today, self.dayCutoff)
|
self.col.log(self.today, self.dayCutoff)
|
||||||
# update all daily counts, but don't save decks to prevent needless
|
# update all daily counts, but don't save decks to prevent needless
|
||||||
# conflicts. we'll save on card answer instead
|
# conflicts. we'll save on card answer instead
|
||||||
|
|
|
@ -45,7 +45,7 @@ class DataModel(QAbstractTableModel):
|
||||||
def getCard(self, index):
|
def getCard(self, index):
|
||||||
id = self.cards[index.row()]
|
id = self.cards[index.row()]
|
||||||
if not id in self.cardObjs:
|
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]
|
return self.cardObjs[id]
|
||||||
|
|
||||||
def refreshNote(self, note):
|
def refreshNote(self, note):
|
||||||
|
|
Loading…
Reference in a new issue