diff --git a/pylib/anki/consts.py b/pylib/anki/consts.py index ddeddd03b..c512f091d 100644 --- a/pylib/anki/consts.py +++ b/pylib/anki/consts.py @@ -17,6 +17,7 @@ NEW_CARDS_DUE = 1 # Queue types QUEUE_TYPE_MANUALLY_BURIED = -3 QUEUE_TYPE_SIBLING_BURIED = -2 +QUEUE_TYPE_SUSPENDED = -1 QUEUE_TYPE_NEW = 0 QUEUE_TYPE_LRN = 1 diff --git a/pylib/anki/sched.py b/pylib/anki/sched.py index 7fcc07257..26e065635 100644 --- a/pylib/anki/sched.py +++ b/pylib/anki/sched.py @@ -893,7 +893,7 @@ select id from cards where did in %s and queue = 2 and due <= ? limit ?)""" card.odue = card.due # if suspended as a leech, nothing to do delay = 0 - if self._checkLeech(card, conf) and card.queue == -1: + if self._checkLeech(card, conf) and card.queue == QUEUE_TYPE_SUSPENDED: return delay # if no relearning steps, nothing to do if not conf["delays"]: @@ -1152,7 +1152,7 @@ did = ?, queue = %s, due = ?, usn = ? where id = ?""" if card.odid: card.did = card.odid card.odue = card.odid = 0 - card.queue = -1 + card.queue = QUEUE_TYPE_SUSPENDED # notify UI hooks.card_did_leech(card) return True @@ -1391,7 +1391,7 @@ To study outside of the normal schedule, click the Custom Study button below.""" self.remFromDyn(ids) self.removeLrn(ids) self.col.db.execute( - "update cards set queue=-1,mod=?,usn=? where id in " + ids2str(ids), + f"update cards set queue={QUEUE_TYPE_SUSPENDED},mod=?,usn=? where id in " + ids2str(ids), intTime(), self.col.usn(), ) @@ -1401,7 +1401,7 @@ To study outside of the normal schedule, click the Custom Study button below.""" self.col.log(ids) self.col.db.execute( "update cards set queue=type,mod=?,usn=? " - "where queue = -1 and id in " + ids2str(ids), + f"where queue = {QUEUE_TYPE_SUSPENDED} and id in " + ids2str(ids), intTime(), self.col.usn(), ) diff --git a/pylib/anki/schedv2.py b/pylib/anki/schedv2.py index 9dc4a4c5d..613e44d1c 100644 --- a/pylib/anki/schedv2.py +++ b/pylib/anki/schedv2.py @@ -976,7 +976,7 @@ select id from cards where did in %s and queue = 2 and due <= ? limit ?)""" card.lapses += 1 card.factor = max(1300, card.factor - 200) - suspended = self._checkLeech(card, conf) and card.queue == -1 + suspended = self._checkLeech(card, conf) and card.queue == QUEUE_TYPE_SUSPENDED if conf["delays"] and not suspended: card.type = CARD_TYPE_RELEARNING @@ -987,7 +987,7 @@ select id from cards where did in %s and queue = 2 and due <= ? limit ?)""" self._rescheduleAsRev(card, conf, early=False) # need to reset the queue after rescheduling if suspended: - card.queue = -1 + card.queue = QUEUE_TYPE_SUSPENDED delay = 0 return delay @@ -1285,7 +1285,7 @@ where id = ? # handle a = conf["leechAction"] if a == LEECH_SUSPEND: - card.queue = -1 + card.queue = QUEUE_TYPE_SUSPENDED # notify UI hooks.card_did_leech(card) return True @@ -1616,7 +1616,7 @@ end) "Suspend cards." self.col.log(ids) self.col.db.execute( - "update cards set queue=-1,mod=?,usn=? where id in " + ids2str(ids), + f"update cards set queue={QUEUE_TYPE_SUSPENDED},mod=?,usn=? where id in " + ids2str(ids), intTime(), self.col.usn(), ) @@ -1625,7 +1625,7 @@ end) "Unsuspend cards." self.col.log(ids) self.col.db.execute( - ("update cards set %s,mod=?,usn=? " "where queue = -1 and id in %s") + (f"update cards set %s,mod=?,usn=? where queue = {QUEUE_TYPE_SUSPENDED} and id in %s") % (self._restoreQueueSnippet, ids2str(ids)), intTime(), self.col.usn(), diff --git a/pylib/tests/test_schedv1.py b/pylib/tests/test_schedv1.py index 9e69873c7..7b75a710e 100644 --- a/pylib/tests/test_schedv1.py +++ b/pylib/tests/test_schedv1.py @@ -376,9 +376,9 @@ def test_reviews(): hooks.card_did_leech.append(onLeech) d.sched.answerCard(c, 1) assert hooked - assert c.queue == -1 + assert c.queue == QUEUE_TYPE_SUSPENDED c.load() - assert c.queue == -1 + assert c.queue == QUEUE_TYPE_SUSPENDED def test_button_spacing(): diff --git a/pylib/tests/test_schedv2.py b/pylib/tests/test_schedv2.py index 88181b100..db76ad460 100644 --- a/pylib/tests/test_schedv2.py +++ b/pylib/tests/test_schedv2.py @@ -398,9 +398,9 @@ def test_reviews(): hooks.card_did_leech.append(onLeech) d.sched.answerCard(c, 1) assert hooked - assert c.queue == -1 + assert c.queue == QUEUE_TYPE_SUSPENDED c.load() - assert c.queue == -1 + assert c.queue == QUEUE_TYPE_SUSPENDED def test_review_limits():