mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
NF: CardQueue type
This commit is contained in:
parent
7ea862931c
commit
365de5f232
4 changed files with 16 additions and 13 deletions
|
@ -39,6 +39,7 @@ class Card:
|
||||||
id: CardID
|
id: CardID
|
||||||
did: anki.decks.DeckID
|
did: anki.decks.DeckID
|
||||||
odid: anki.decks.DeckID
|
odid: anki.decks.DeckID
|
||||||
|
queue: CardQueue
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, col: anki.collection.Collection, id: Optional[CardID] = None
|
self, col: anki.collection.Collection, id: Optional[CardID] = None
|
||||||
|
@ -69,7 +70,7 @@ class Card:
|
||||||
self.mod = c.mtime_secs
|
self.mod = c.mtime_secs
|
||||||
self.usn = c.usn
|
self.usn = c.usn
|
||||||
self.type = c.ctype
|
self.type = c.ctype
|
||||||
self.queue = c.queue
|
self.queue = CardQueue(c.queue)
|
||||||
self.due = c.due
|
self.due = c.due
|
||||||
self.ivl = c.interval
|
self.ivl = c.interval
|
||||||
self.factor = c.ease_factor
|
self.factor = c.ease_factor
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, NewType, Optional
|
||||||
|
|
||||||
import anki
|
import anki
|
||||||
from anki.lang import TR
|
from anki.lang import TR
|
||||||
|
@ -18,14 +18,15 @@ NEW_CARDS_RANDOM = 0
|
||||||
NEW_CARDS_DUE = 1
|
NEW_CARDS_DUE = 1
|
||||||
|
|
||||||
# Queue types
|
# Queue types
|
||||||
QUEUE_TYPE_MANUALLY_BURIED = -3
|
CardQueue = NewType("CardQueue", int)
|
||||||
QUEUE_TYPE_SIBLING_BURIED = -2
|
QUEUE_TYPE_MANUALLY_BURIED = CardQueue(-3)
|
||||||
QUEUE_TYPE_SUSPENDED = -1
|
QUEUE_TYPE_SIBLING_BURIED = CardQueue(-2)
|
||||||
QUEUE_TYPE_NEW = 0
|
QUEUE_TYPE_SUSPENDED = CardQueue(-1)
|
||||||
QUEUE_TYPE_LRN = 1
|
QUEUE_TYPE_NEW = CardQueue(0)
|
||||||
QUEUE_TYPE_REV = 2
|
QUEUE_TYPE_LRN = CardQueue(1)
|
||||||
QUEUE_TYPE_DAY_LEARN_RELEARN = 3
|
QUEUE_TYPE_REV = CardQueue(2)
|
||||||
QUEUE_TYPE_PREVIEW = 4
|
QUEUE_TYPE_DAY_LEARN_RELEARN = CardQueue(3)
|
||||||
|
QUEUE_TYPE_PREVIEW = CardQueue(4)
|
||||||
|
|
||||||
# Card types
|
# Card types
|
||||||
CARD_TYPE_NEW = 0
|
CARD_TYPE_NEW = 0
|
||||||
|
|
|
@ -98,7 +98,7 @@ class Scheduler(V2):
|
||||||
if card:
|
if card:
|
||||||
idx = self.countIdx(card)
|
idx = self.countIdx(card)
|
||||||
if idx == QUEUE_TYPE_LRN:
|
if idx == QUEUE_TYPE_LRN:
|
||||||
counts[QUEUE_TYPE_LRN] += card.left // 1000
|
counts[int(QUEUE_TYPE_LRN)] += card.left // 1000
|
||||||
else:
|
else:
|
||||||
counts[idx] += 1
|
counts[idx] += 1
|
||||||
|
|
||||||
|
@ -303,7 +303,8 @@ limit %d"""
|
||||||
card.odid = DeckID(0)
|
card.odid = DeckID(0)
|
||||||
# if rescheduling is off, it needs to be set back to a new card
|
# if rescheduling is off, it needs to be set back to a new card
|
||||||
if not resched and not lapse:
|
if not resched and not lapse:
|
||||||
card.queue = card.type = CARD_TYPE_NEW
|
card.queue = QUEUE_TYPE_NEW
|
||||||
|
card.type = CARD_TYPE_NEW
|
||||||
card.due = self.col.nextID("pos")
|
card.due = self.col.nextID("pos")
|
||||||
|
|
||||||
def _startingLeft(self, card: Card) -> int:
|
def _startingLeft(self, card: Card) -> int:
|
||||||
|
|
|
@ -805,7 +805,7 @@ limit ?"""
|
||||||
else:
|
else:
|
||||||
card.queue = QUEUE_TYPE_DAY_LEARN_RELEARN
|
card.queue = QUEUE_TYPE_DAY_LEARN_RELEARN
|
||||||
else:
|
else:
|
||||||
card.queue = card.type
|
card.queue = CardQueue(card.type)
|
||||||
|
|
||||||
# Answering a review card
|
# Answering a review card
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
Loading…
Reference in a new issue