QUEUE_TYPE_SIBLING_BURIED

This commit is contained in:
Arthur Milchior 2020-01-30 19:40:51 -08:00
parent 4a21911d74
commit 9fc3f17f5c
5 changed files with 15 additions and 15 deletions

View file

@ -16,6 +16,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_NEW = 0 QUEUE_TYPE_NEW = 0
QUEUE_TYPE_LRN = 1 QUEUE_TYPE_LRN = 1

View file

@ -278,7 +278,7 @@ select distinct(n.id) from cards c, notes n where c.nid=n.id and """
elif val == "suspended": elif val == "suspended":
return "c.queue = -1" return "c.queue = -1"
elif val == "buried": elif val == "buried":
return f"c.queue in (-2, {QUEUE_TYPE_MANUALLY_BURIED})" return f"c.queue in ({QUEUE_TYPE_SIBLING_BURIED}, {QUEUE_TYPE_MANUALLY_BURIED})"
elif val == "due": elif val == "due":
return f""" return f"""
(c.queue in (2,3) and c.due <= %d) or (c.queue in (2,3) and c.due <= %d) or

View file

@ -153,18 +153,18 @@ order by due"""
def unburyCards(self): def unburyCards(self):
"Unbury cards." "Unbury cards."
self.col.conf["lastUnburied"] = self.today self.col.conf["lastUnburied"] = self.today
self.col.log(self.col.db.list("select id from cards where queue = -2")) self.col.log(self.col.db.list(f"select id from cards where queue = {QUEUE_TYPE_SIBLING_BURIED}"))
self.col.db.execute("update cards set queue=type where queue = -2") self.col.db.execute(f"update cards set queue=type where queue = {QUEUE_TYPE_SIBLING_BURIED}")
def unburyCardsForDeck(self): def unburyCardsForDeck(self):
sids = ids2str(self.col.decks.active()) sids = ids2str(self.col.decks.active())
self.col.log( self.col.log(
self.col.db.list( self.col.db.list(
"select id from cards where queue = -2 and did in %s" % sids f"select id from cards where queue = {QUEUE_TYPE_SIBLING_BURIED} and did in %s" % sids
) )
) )
self.col.db.execute( self.col.db.execute(
"update cards set mod=?,usn=?,queue=type where queue = -2 and did in %s" f"update cards set mod=?,usn=?,queue=type where queue = {QUEUE_TYPE_SIBLING_BURIED} and did in %s"
% sids, % sids,
intTime(), intTime(),
self.col.usn(), self.col.usn(),
@ -1328,7 +1328,7 @@ To study outside of the normal schedule, click the Custom Study button below."""
def haveBuried(self): def haveBuried(self):
sdids = ids2str(self.col.decks.active()) sdids = ids2str(self.col.decks.active())
cnt = self.col.db.scalar( cnt = self.col.db.scalar(
"select 1 from cards where queue = -2 and did in %s limit 1" % sdids f"select 1 from cards where queue = {QUEUE_TYPE_SIBLING_BURIED} and did in %s limit 1" % sdids
) )
return not not cnt return not not cnt
@ -1411,8 +1411,8 @@ To study outside of the normal schedule, click the Custom Study button below."""
self.remFromDyn(cids) self.remFromDyn(cids)
self.removeLrn(cids) self.removeLrn(cids)
self.col.db.execute( self.col.db.execute(
""" f"""
update cards set queue=-2,mod=?,usn=? where id in """ update cards set queue={QUEUE_TYPE_SIBLING_BURIED},mod=?,usn=? where id in """
+ ids2str(cids), + ids2str(cids),
intTime(), intTime(),
self.col.usn(), self.col.usn(),
@ -1462,7 +1462,7 @@ and (queue={QUEUE_TYPE_NEW} or (queue=2 and due<=?))""",
# then bury # then bury
if toBury: if toBury:
self.col.db.execute( self.col.db.execute(
"update cards set queue=-2,mod=?,usn=? where id in " + ids2str(toBury), f"update cards set queue={QUEUE_TYPE_SIBLING_BURIED},mod=?,usn=? where id in " + ids2str(toBury),
intTime(), intTime(),
self.col.usn(), self.col.usn(),
) )

View file

@ -27,7 +27,6 @@ CARD_TYPE_RELEARNING = 3
# 4=preview, -1=suspended, -2=sibling buried, -3=manually buried # 4=preview, -1=suspended, -2=sibling buried, -3=manually buried
QUEUE_TYPE_PREVIEW = 4 QUEUE_TYPE_PREVIEW = 4
QUEUE_TYPE_DAY_LEARN_RELEARN = 3 QUEUE_TYPE_DAY_LEARN_RELEARN = 3
QUEUE_TYPE_SIBLING_BURIED = -2
# revlog types: 0=lrn, 1=rev, 2=relrn, 3=early review # revlog types: 0=lrn, 1=rev, 2=relrn, 3=early review
# positive revlog intervals are in days (rev), negative in seconds (lrn) # positive revlog intervals are in days (rev), negative in seconds (lrn)
@ -1655,11 +1654,11 @@ update cards set queue=?,mod=?,usn=? where id in """
"Unbury all buried cards in all decks." "Unbury all buried cards in all decks."
self.col.log( self.col.log(
self.col.db.list( self.col.db.list(
f"select id from cards where queue in (-2, {QUEUE_TYPE_MANUALLY_BURIED})" f"select id from cards where queue in ({QUEUE_TYPE_SIBLING_BURIED}, {QUEUE_TYPE_MANUALLY_BURIED})"
) )
) )
self.col.db.execute( self.col.db.execute(
f"update cards set %s where queue in (-2, {QUEUE_TYPE_MANUALLY_BURIED})" f"update cards set %s where queue in ({QUEUE_TYPE_SIBLING_BURIED}, {QUEUE_TYPE_MANUALLY_BURIED})"
% self._restoreQueueSnippet % self._restoreQueueSnippet
) )

View file

@ -627,7 +627,7 @@ def test_bury():
assert c.queue == QUEUE_TYPE_MANUALLY_BURIED assert c.queue == QUEUE_TYPE_MANUALLY_BURIED
d.sched.buryCards([c2.id], manual=False) # pylint: disable=unexpected-keyword-arg d.sched.buryCards([c2.id], manual=False) # pylint: disable=unexpected-keyword-arg
c2.load() c2.load()
assert c2.queue == -2 assert c2.queue == QUEUE_TYPE_SIBLING_BURIED
d.reset() d.reset()
assert not d.sched.getCard() assert not d.sched.getCard()
@ -636,7 +636,7 @@ def test_bury():
c.load() c.load()
assert c.queue == QUEUE_TYPE_NEW assert c.queue == QUEUE_TYPE_NEW
c2.load() c2.load()
assert c2.queue == -2 assert c2.queue == QUEUE_TYPE_SIBLING_BURIED
d.sched.unburyCardsForDeck( # pylint: disable=unexpected-keyword-arg d.sched.unburyCardsForDeck( # pylint: disable=unexpected-keyword-arg
type="siblings" type="siblings"
@ -1233,7 +1233,7 @@ def test_moveVersions():
# card should have moved queues # card should have moved queues
c.load() c.load()
assert c.queue == -2 assert c.queue == QUEUE_TYPE_SIBLING_BURIED
# and it should be new again when unburied # and it should be new again when unburied
col.sched.unburyCards() col.sched.unburyCards()