mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
move re-queuing out of _answerCard()
This commit is contained in:
parent
a112a4403a
commit
63df7ee7a9
1 changed files with 29 additions and 10 deletions
|
@ -480,6 +480,8 @@ limit ?"""
|
||||||
|
|
||||||
self._answerCard(card, ease)
|
self._answerCard(card, ease)
|
||||||
|
|
||||||
|
self._maybe_requeue_card(card)
|
||||||
|
|
||||||
card.mod = intTime()
|
card.mod = intTime()
|
||||||
card.usn = self.col.usn()
|
card.usn = self.col.usn()
|
||||||
card.flush()
|
card.flush()
|
||||||
|
@ -522,6 +524,33 @@ limit ?"""
|
||||||
if card.odue:
|
if card.odue:
|
||||||
card.odue = 0
|
card.odue = 0
|
||||||
|
|
||||||
|
def _maybe_requeue_card(self, card: Card) -> None:
|
||||||
|
# preview cards
|
||||||
|
if card.queue == QUEUE_TYPE_PREVIEW:
|
||||||
|
# adjust the count immediately, and rely on the once a minute
|
||||||
|
# checks to requeue it
|
||||||
|
self.lrnCount += 1
|
||||||
|
return
|
||||||
|
|
||||||
|
# learning cards
|
||||||
|
if not card.queue == QUEUE_TYPE_LRN:
|
||||||
|
return
|
||||||
|
if card.due >= (intTime() + self.col.conf["collapseTime"]):
|
||||||
|
return
|
||||||
|
|
||||||
|
# card is due within collapse time, so we'll want to add it
|
||||||
|
# back to the learning queue
|
||||||
|
self.lrnCount += 1
|
||||||
|
|
||||||
|
# if the queue is not empty and there's nothing else to do, make
|
||||||
|
# sure we don't put it at the head of the queue and end up showing
|
||||||
|
# it twice in a row
|
||||||
|
if self._lrnQueue and not self.revCount and not self.newCount:
|
||||||
|
smallestDue = self._lrnQueue[0][0]
|
||||||
|
card.due = max(card.due, smallestDue + 1)
|
||||||
|
|
||||||
|
heappush(self._lrnQueue, (card.due, card.id))
|
||||||
|
|
||||||
def _cardConf(self, card: Card) -> DeckConfig:
|
def _cardConf(self, card: Card) -> DeckConfig:
|
||||||
return self.col.decks.confForDid(card.did)
|
return self.col.decks.confForDid(card.did)
|
||||||
|
|
||||||
|
@ -637,15 +666,6 @@ limit ?"""
|
||||||
fuzz = random.randrange(0, max(1, maxExtra))
|
fuzz = random.randrange(0, max(1, maxExtra))
|
||||||
card.due = min(self.dayCutoff - 1, card.due + fuzz)
|
card.due = min(self.dayCutoff - 1, card.due + fuzz)
|
||||||
card.queue = QUEUE_TYPE_LRN
|
card.queue = QUEUE_TYPE_LRN
|
||||||
if card.due < (intTime() + self.col.conf["collapseTime"]):
|
|
||||||
self.lrnCount += 1
|
|
||||||
# if the queue is not empty and there's nothing else to do, make
|
|
||||||
# sure we don't put it at the head of the queue and end up showing
|
|
||||||
# it twice in a row
|
|
||||||
if self._lrnQueue and not self.revCount and not self.newCount:
|
|
||||||
smallestDue = self._lrnQueue[0][0]
|
|
||||||
card.due = max(card.due, smallestDue + 1)
|
|
||||||
heappush(self._lrnQueue, (card.due, card.id))
|
|
||||||
else:
|
else:
|
||||||
# the card is due in one or more days, so we need to use the
|
# the card is due in one or more days, so we need to use the
|
||||||
# day learn queue
|
# day learn queue
|
||||||
|
@ -799,7 +819,6 @@ limit ?"""
|
||||||
# repeat after delay
|
# repeat after delay
|
||||||
card.queue = QUEUE_TYPE_PREVIEW
|
card.queue = QUEUE_TYPE_PREVIEW
|
||||||
card.due = intTime() + self._previewDelay(card)
|
card.due = intTime() + self._previewDelay(card)
|
||||||
self.lrnCount += 1
|
|
||||||
else:
|
else:
|
||||||
# BUTTON_TWO
|
# BUTTON_TWO
|
||||||
# restore original card state and remove from filtered deck
|
# restore original card state and remove from filtered deck
|
||||||
|
|
Loading…
Reference in a new issue