mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
update learning cutoff time periodically
prevents users from having to leave and return to the deck to show cards that have become due during the study session https://anki.tenderapp.com/discussions/ankimobile/8530-ankimobile-with-experimental-schedule-not-showing-due-cards-in-realtime
This commit is contained in:
parent
ed665557d5
commit
7cb58c3432
1 changed files with 16 additions and 3 deletions
|
@ -34,6 +34,7 @@ class Scheduler:
|
||||||
self.reps = 0
|
self.reps = 0
|
||||||
self.today = None
|
self.today = None
|
||||||
self._haveQueues = False
|
self._haveQueues = False
|
||||||
|
self._lrnCutoff = 0
|
||||||
self._updateCutoff()
|
self._updateCutoff()
|
||||||
|
|
||||||
def getCard(self):
|
def getCard(self):
|
||||||
|
@ -433,15 +434,25 @@ select id from cards where did in %s and queue = 0 limit ?)"""
|
||||||
# Learning queues
|
# Learning queues
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
def _resetLrnCount(self):
|
# scan for any newly due learning cards every 5 minutes
|
||||||
cutoff = intTime() + self.col.conf['collapseTime']
|
def _updateLrnCutoff(self, force):
|
||||||
|
nextCutoff = intTime() + self.col.conf['collapseTime']
|
||||||
|
if nextCutoff - self._lrnCutoff > 300 or force:
|
||||||
|
self._lrnCutoff = nextCutoff
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _maybeResetLrn(self, force):
|
||||||
|
if self._updateLrnCutoff(force):
|
||||||
|
self._resetLrn()
|
||||||
|
|
||||||
|
def _resetLrnCount(self):
|
||||||
# sub-day
|
# sub-day
|
||||||
self.lrnCount = self.col.db.scalar("""
|
self.lrnCount = self.col.db.scalar("""
|
||||||
select count() from cards where did in %s and queue = 1
|
select count() from cards where did in %s and queue = 1
|
||||||
and due < ?""" % (
|
and due < ?""" % (
|
||||||
self._deckLimit()),
|
self._deckLimit()),
|
||||||
cutoff) or 0
|
self._lrnCutoff) or 0
|
||||||
# day
|
# day
|
||||||
self.lrnCount += self.col.db.scalar("""
|
self.lrnCount += self.col.db.scalar("""
|
||||||
select count() from cards where did in %s and queue = 3
|
select count() from cards where did in %s and queue = 3
|
||||||
|
@ -453,6 +464,7 @@ select count() from cards where did in %s and queue = 4
|
||||||
""" % (self._deckLimit()))
|
""" % (self._deckLimit()))
|
||||||
|
|
||||||
def _resetLrn(self):
|
def _resetLrn(self):
|
||||||
|
self._updateLrnCutoff(force=True)
|
||||||
self._resetLrnCount()
|
self._resetLrnCount()
|
||||||
self._lrnQueue = []
|
self._lrnQueue = []
|
||||||
self._lrnDayQueue = []
|
self._lrnDayQueue = []
|
||||||
|
@ -474,6 +486,7 @@ limit %d""" % (self._deckLimit(), self.reportLimit), lim=cutoff)
|
||||||
return self._lrnQueue
|
return self._lrnQueue
|
||||||
|
|
||||||
def _getLrnCard(self, collapse=False):
|
def _getLrnCard(self, collapse=False):
|
||||||
|
self._maybeResetLrn(force=collapse and self.lrnCount == 0)
|
||||||
if self._fillLrn():
|
if self._fillLrn():
|
||||||
cutoff = time.time()
|
cutoff = time.time()
|
||||||
if collapse:
|
if collapse:
|
||||||
|
|
Loading…
Reference in a new issue