diff --git a/anki/sched.py b/anki/sched.py index 52d2f0c97..931061eee 100644 --- a/anki/sched.py +++ b/anki/sched.py @@ -662,26 +662,24 @@ did = ? and queue = 3 and due <= ? limit ?""", time.sleep(0.01) log() - def removeFailed(self, ids=None, expiredOnly=False): - "Remove failed cards from the learning queue." + def removeLrn(self, ids=None): + "Remove cards from the learning queues." if ids: extra = " and id in "+ids2str(ids) else: # benchmarks indicate it's about 10x faster to search all decks # with the index than scan the table extra = " and did in "+ids2str(self.col.decks.allIds()) - if expiredOnly: - extra += " and odue <= %d" % self.today - mod = self.col.db.mod + # review cards in relearning self.col.db.execute(""" update cards set due = odue, queue = 2, mod = %d, usn = %d, odue = 0 -where queue = 1 and type = 2 +where queue in (1,3) and type = 2 %s """ % (intTime(), self.col.usn(), extra)) - if expiredOnly: - # we don't want to bump the mod time when removing expired - self.col.db.mod = mod + # new cards in learning + self.forgetCards(self.col.db.list( + "select id from cards where queue in (1,3) %s" % extra)) def _lrnForDeck(self, did): cnt = self.col.db.scalar( @@ -1216,7 +1214,7 @@ To study outside of the normal schedule, click the Custom Study button below.""" def suspendCards(self, ids): "Suspend cards." self.remFromDyn(ids) - self.removeFailed(ids) + self.removeLrn(ids) self.col.db.execute( "update cards set queue=-1,mod=?,usn=? where id in "+ ids2str(ids), intTime(), self.col.usn()) diff --git a/tests/test_sched.py b/tests/test_sched.py index cbb2190c0..bcf88c956 100644 --- a/tests/test_sched.py +++ b/tests/test_sched.py @@ -165,7 +165,7 @@ def test_learn(): c.queue = 1 c.odue = 321 c.flush() - d.sched.removeFailed() + d.sched.removeLrn() c.load() assert c.queue == 2 assert c.due == 321