ensure cards are scheduled past cutoff, more

- because the cutoff adds a few hours past midnight, it's possible for a card
  that's scheduled for 1.0 days ahead to fall within the current cutoff, so we
  need to make sure that doesn't happen
- set spaceUntil=0 when answering card again
- fix randomizeNewCards() query. the whole codebase needs auditing for type
  references which need updating
This commit is contained in:
Damien Elmes 2010-11-07 06:48:35 +09:00
parent 61610d8351
commit 9d6b0f35f4

View file

@ -763,6 +763,7 @@ where id in """
card.due = self.nextDue(card, ease, oldState) card.due = self.nextDue(card, ease, oldState)
card.isDue = 0 card.isDue = 0
card.lastFactor = card.factor card.lastFactor = card.factor
card.spaceUntil = 0;
if lastDelay >= 0: if lastDelay >= 0:
# don't update factor if learning ahead # don't update factor if learning ahead
self.updateFactor(card, ease) self.updateFactor(card, ease)
@ -780,8 +781,9 @@ where id in """
self.newCount -= 1 self.newCount -= 1
# card stats # card stats
anki.cards.Card.updateStats(card, ease, oldState) anki.cards.Card.updateStats(card, ease, oldState)
# update type # update type & ensure past cutoff
card.type = self.cardType(card) card.type = self.cardType(card)
card.due = max(card.due, this.dueCutoff+1)
# allow custom schedulers to munge the card # allow custom schedulers to munge the card
if self.answerPreSave: if self.answerPreSave:
self.answerPreSave(card, ease) self.answerPreSave(card, ease)
@ -985,7 +987,7 @@ where id in %s""" % ids2str(ids), now=time.time(), new=0)
def randomizeNewCards(self, cardIds=None): def randomizeNewCards(self, cardIds=None):
"Randomize 'due' on all new cards." "Randomize 'due' on all new cards."
now = time.time() now = time.time()
query = "select distinct factId from cards where type = 2" query = "select distinct factId from cards where reps = 0"
if cardIds: if cardIds:
query += " and id in %s" % ids2str(cardIds) query += " and id in %s" % ids2str(cardIds)
fids = self.s.column0(query) fids = self.s.column0(query)