mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
Merge pull request #406 from agentydragon/named_card_type_5
Add constant for day learn/relearn queue
This commit is contained in:
commit
252d9172e7
1 changed files with 21 additions and 15 deletions
|
@ -24,6 +24,7 @@ CARD_TYPE_RELEARNING = 3
|
||||||
# queue types: 0=new, 1=(re)lrn, 2=rev, 3=day (re)lrn,
|
# queue types: 0=new, 1=(re)lrn, 2=rev, 3=day (re)lrn,
|
||||||
# 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_SIBLING_BURIED = -2
|
QUEUE_TYPE_SIBLING_BURIED = -2
|
||||||
QUEUE_TYPE_MANUALLY_BURIED = -3
|
QUEUE_TYPE_MANUALLY_BURIED = -3
|
||||||
# revlog types: 0=lrn, 1=rev, 2=relrn, 3=early review
|
# revlog types: 0=lrn, 1=rev, 2=relrn, 3=early review
|
||||||
|
@ -101,7 +102,7 @@ class Scheduler:
|
||||||
# update daily limit
|
# update daily limit
|
||||||
self._updateStats(card, "new")
|
self._updateStats(card, "new")
|
||||||
|
|
||||||
if card.queue in (1, 3):
|
if card.queue in (1, QUEUE_TYPE_DAY_LEARN_RELEARN):
|
||||||
self._answerLrnCard(card, ease)
|
self._answerLrnCard(card, ease)
|
||||||
elif card.queue == 2:
|
elif card.queue == 2:
|
||||||
self._answerRevCard(card, ease)
|
self._answerRevCard(card, ease)
|
||||||
|
@ -159,7 +160,7 @@ order by due"""
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def countIdx(self, card: Card) -> Any:
|
def countIdx(self, card: Card) -> Any:
|
||||||
if card.queue in (3, QUEUE_TYPE_PREVIEW):
|
if card.queue in (QUEUE_TYPE_DAY_LEARN_RELEARN, QUEUE_TYPE_PREVIEW):
|
||||||
return 1
|
return 1
|
||||||
return card.queue
|
return card.queue
|
||||||
|
|
||||||
|
@ -511,8 +512,8 @@ and due < ?"""
|
||||||
)
|
)
|
||||||
# day
|
# day
|
||||||
self.lrnCount += self.col.db.scalar(
|
self.lrnCount += self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select count() from cards where did in %s and queue = 3
|
select count() from cards where did in %s and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN}
|
||||||
and due <= ?"""
|
and due <= ?"""
|
||||||
% (self._deckLimit()),
|
% (self._deckLimit()),
|
||||||
self.today,
|
self.today,
|
||||||
|
@ -574,9 +575,9 @@ limit %d"""
|
||||||
did = self._lrnDids[0]
|
did = self._lrnDids[0]
|
||||||
# fill the queue with the current did
|
# fill the queue with the current did
|
||||||
self._lrnDayQueue = self.col.db.list(
|
self._lrnDayQueue = self.col.db.list(
|
||||||
"""
|
f"""
|
||||||
select id from cards where
|
select id from cards where
|
||||||
did = ? and queue = 3 and due <= ? limit ?""",
|
did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN} and due <= ? limit ?""",
|
||||||
did,
|
did,
|
||||||
self.today,
|
self.today,
|
||||||
self.queueLimit,
|
self.queueLimit,
|
||||||
|
@ -685,7 +686,7 @@ did = ? and queue = 3 and due <= ? limit ?""",
|
||||||
# day learn queue
|
# day learn queue
|
||||||
ahead = ((card.due - self.dayCutoff) // 86400) + 1
|
ahead = ((card.due - self.dayCutoff) // 86400) + 1
|
||||||
card.due = self.today + ahead
|
card.due = self.today + ahead
|
||||||
card.queue = 3
|
card.queue = QUEUE_TYPE_DAY_LEARN_RELEARN
|
||||||
return delay
|
return delay
|
||||||
|
|
||||||
def _delayForGrade(self, conf: Dict[str, Any], left: int) -> Any:
|
def _delayForGrade(self, conf: Dict[str, Any], left: int) -> Any:
|
||||||
|
@ -831,9 +832,9 @@ select count() from
|
||||||
or 0
|
or 0
|
||||||
)
|
)
|
||||||
return cnt + self.col.db.scalar(
|
return cnt + self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select count() from
|
select count() from
|
||||||
(select null from cards where did = ? and queue = 3
|
(select null from cards where did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN}
|
||||||
and due <= ? limit ?)""",
|
and due <= ? limit ?)""",
|
||||||
did,
|
did,
|
||||||
self.today,
|
self.today,
|
||||||
|
@ -1244,7 +1245,7 @@ where id = ?
|
||||||
if card.odue > 1000000000:
|
if card.odue > 1000000000:
|
||||||
card.queue = 1
|
card.queue = 1
|
||||||
else:
|
else:
|
||||||
card.queue = 3
|
card.queue = QUEUE_TYPE_DAY_LEARN_RELEARN
|
||||||
else:
|
else:
|
||||||
card.queue = card.type
|
card.queue = card.type
|
||||||
|
|
||||||
|
@ -1521,7 +1522,7 @@ To study outside of the normal schedule, click the Custom Study button below."""
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
# (re)learning?
|
# (re)learning?
|
||||||
if card.queue in (0, 1, 3):
|
if card.queue in (0, 1, QUEUE_TYPE_DAY_LEARN_RELEARN):
|
||||||
return self._nextLrnIvl(card, ease)
|
return self._nextLrnIvl(card, ease)
|
||||||
elif ease == 1:
|
elif ease == 1:
|
||||||
# lapse
|
# lapse
|
||||||
|
@ -1564,7 +1565,8 @@ To study outside of the normal schedule, click the Custom Study button below."""
|
||||||
# other types map directly to queues
|
# other types map directly to queues
|
||||||
_restoreQueueSnippet = f"""
|
_restoreQueueSnippet = f"""
|
||||||
queue = (case when type in (1,{CARD_TYPE_RELEARNING}) then
|
queue = (case when type in (1,{CARD_TYPE_RELEARNING}) then
|
||||||
(case when (case when odue then odue else due end) > 1000000000 then 1 else 3 end)
|
(case when (case when odue then odue else due end) > 1000000000 then 1 else
|
||||||
|
{QUEUE_TYPE_DAY_LEARN_RELEARN} end)
|
||||||
else
|
else
|
||||||
type
|
type
|
||||||
end)
|
end)
|
||||||
|
@ -1849,7 +1851,7 @@ due = odue, odue = 0, odid = 0, usn = ? where odid != 0""",
|
||||||
f"""
|
f"""
|
||||||
update cards set
|
update cards set
|
||||||
due = odue, queue = 2, type = 2, mod = %d, usn = %d, odue = 0
|
due = odue, queue = 2, type = 2, mod = %d, usn = %d, odue = 0
|
||||||
where queue in (1,3) and type in (2, {CARD_TYPE_RELEARNING})
|
where queue in (1,{QUEUE_TYPE_DAY_LEARN_RELEARN}) and type in (2, {CARD_TYPE_RELEARNING})
|
||||||
"""
|
"""
|
||||||
% (intTime(), self.col.usn())
|
% (intTime(), self.col.usn())
|
||||||
)
|
)
|
||||||
|
@ -1858,12 +1860,16 @@ due = odue, odue = 0, odid = 0, usn = ? where odid != 0""",
|
||||||
f"""
|
f"""
|
||||||
update cards set
|
update cards set
|
||||||
due = %d+ivl, queue = 2, type = 2, mod = %d, usn = %d, odue = 0
|
due = %d+ivl, queue = 2, type = 2, mod = %d, usn = %d, odue = 0
|
||||||
where queue in (1,3) and type in (2, {CARD_TYPE_RELEARNING})
|
where queue in (1,{QUEUE_TYPE_DAY_LEARN_RELEARN}) and type in (2, {CARD_TYPE_RELEARNING})
|
||||||
"""
|
"""
|
||||||
% (self.today, intTime(), self.col.usn())
|
% (self.today, intTime(), self.col.usn())
|
||||||
)
|
)
|
||||||
# remove new cards from learning
|
# remove new cards from learning
|
||||||
self.forgetCards(self.col.db.list("select id from cards where queue in (1,3)"))
|
self.forgetCards(
|
||||||
|
self.col.db.list(
|
||||||
|
f"select id from cards where queue in (1,{QUEUE_TYPE_DAY_LEARN_RELEARN})"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# v1 doesn't support buried/suspended (re)learning cards
|
# v1 doesn't support buried/suspended (re)learning cards
|
||||||
def _resetSuspendedLearning(self) -> None:
|
def _resetSuspendedLearning(self) -> None:
|
||||||
|
|
Loading…
Reference in a new issue