QUEUE_TYPE_SUSPENDED

This commit is contained in:
Arthur Milchior 2020-01-30 19:48:14 -08:00
parent 9fc3f17f5c
commit 7d4506afdb
5 changed files with 14 additions and 13 deletions

View File

@ -17,6 +17,7 @@ NEW_CARDS_DUE = 1
# Queue types # Queue types
QUEUE_TYPE_MANUALLY_BURIED = -3 QUEUE_TYPE_MANUALLY_BURIED = -3
QUEUE_TYPE_SIBLING_BURIED = -2 QUEUE_TYPE_SIBLING_BURIED = -2
QUEUE_TYPE_SUSPENDED = -1
QUEUE_TYPE_NEW = 0 QUEUE_TYPE_NEW = 0
QUEUE_TYPE_LRN = 1 QUEUE_TYPE_LRN = 1

View File

@ -893,7 +893,7 @@ select id from cards where did in %s and queue = 2 and due <= ? limit ?)"""
card.odue = card.due card.odue = card.due
# if suspended as a leech, nothing to do # if suspended as a leech, nothing to do
delay = 0 delay = 0
if self._checkLeech(card, conf) and card.queue == -1: if self._checkLeech(card, conf) and card.queue == QUEUE_TYPE_SUSPENDED:
return delay return delay
# if no relearning steps, nothing to do # if no relearning steps, nothing to do
if not conf["delays"]: if not conf["delays"]:
@ -1152,7 +1152,7 @@ did = ?, queue = %s, due = ?, usn = ? where id = ?"""
if card.odid: if card.odid:
card.did = card.odid card.did = card.odid
card.odue = card.odid = 0 card.odue = card.odid = 0
card.queue = -1 card.queue = QUEUE_TYPE_SUSPENDED
# notify UI # notify UI
hooks.card_did_leech(card) hooks.card_did_leech(card)
return True return True
@ -1391,7 +1391,7 @@ To study outside of the normal schedule, click the Custom Study button below."""
self.remFromDyn(ids) self.remFromDyn(ids)
self.removeLrn(ids) self.removeLrn(ids)
self.col.db.execute( 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(), intTime(),
self.col.usn(), 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.log(ids)
self.col.db.execute( self.col.db.execute(
"update cards set queue=type,mod=?,usn=? " "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(), intTime(),
self.col.usn(), self.col.usn(),
) )

View File

@ -976,7 +976,7 @@ select id from cards where did in %s and queue = 2 and due <= ? limit ?)"""
card.lapses += 1 card.lapses += 1
card.factor = max(1300, card.factor - 200) 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: if conf["delays"] and not suspended:
card.type = CARD_TYPE_RELEARNING 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) self._rescheduleAsRev(card, conf, early=False)
# need to reset the queue after rescheduling # need to reset the queue after rescheduling
if suspended: if suspended:
card.queue = -1 card.queue = QUEUE_TYPE_SUSPENDED
delay = 0 delay = 0
return delay return delay
@ -1285,7 +1285,7 @@ where id = ?
# handle # handle
a = conf["leechAction"] a = conf["leechAction"]
if a == LEECH_SUSPEND: if a == LEECH_SUSPEND:
card.queue = -1 card.queue = QUEUE_TYPE_SUSPENDED
# notify UI # notify UI
hooks.card_did_leech(card) hooks.card_did_leech(card)
return True return True
@ -1616,7 +1616,7 @@ end)
"Suspend cards." "Suspend cards."
self.col.log(ids) self.col.log(ids)
self.col.db.execute( 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(), intTime(),
self.col.usn(), self.col.usn(),
) )
@ -1625,7 +1625,7 @@ end)
"Unsuspend cards." "Unsuspend cards."
self.col.log(ids) self.col.log(ids)
self.col.db.execute( 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)), % (self._restoreQueueSnippet, ids2str(ids)),
intTime(), intTime(),
self.col.usn(), self.col.usn(),

View File

@ -376,9 +376,9 @@ def test_reviews():
hooks.card_did_leech.append(onLeech) hooks.card_did_leech.append(onLeech)
d.sched.answerCard(c, 1) d.sched.answerCard(c, 1)
assert hooked assert hooked
assert c.queue == -1 assert c.queue == QUEUE_TYPE_SUSPENDED
c.load() c.load()
assert c.queue == -1 assert c.queue == QUEUE_TYPE_SUSPENDED
def test_button_spacing(): def test_button_spacing():

View File

@ -398,9 +398,9 @@ def test_reviews():
hooks.card_did_leech.append(onLeech) hooks.card_did_leech.append(onLeech)
d.sched.answerCard(c, 1) d.sched.answerCard(c, 1)
assert hooked assert hooked
assert c.queue == -1 assert c.queue == QUEUE_TYPE_SUSPENDED
c.load() c.load()
assert c.queue == -1 assert c.queue == QUEUE_TYPE_SUSPENDED
def test_review_limits(): def test_review_limits():