NF: CardQueue type

This commit is contained in:
Arthur Milchior 2021-03-23 13:14:57 +01:00 committed by Damien Elmes
parent 7ea862931c
commit 365de5f232
4 changed files with 16 additions and 13 deletions

View file

@ -39,6 +39,7 @@ class Card:
id: CardID
did: anki.decks.DeckID
odid: anki.decks.DeckID
queue: CardQueue
def __init__(
self, col: anki.collection.Collection, id: Optional[CardID] = None
@ -69,7 +70,7 @@ class Card:
self.mod = c.mtime_secs
self.usn = c.usn
self.type = c.ctype
self.queue = c.queue
self.queue = CardQueue(c.queue)
self.due = c.due
self.ivl = c.interval
self.factor = c.ease_factor

View file

@ -3,7 +3,7 @@
from __future__ import annotations
from typing import Any, Dict, Optional
from typing import Any, Dict, NewType, Optional
import anki
from anki.lang import TR
@ -18,14 +18,15 @@ NEW_CARDS_RANDOM = 0
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
QUEUE_TYPE_REV = 2
QUEUE_TYPE_DAY_LEARN_RELEARN = 3
QUEUE_TYPE_PREVIEW = 4
CardQueue = NewType("CardQueue", int)
QUEUE_TYPE_MANUALLY_BURIED = CardQueue(-3)
QUEUE_TYPE_SIBLING_BURIED = CardQueue(-2)
QUEUE_TYPE_SUSPENDED = CardQueue(-1)
QUEUE_TYPE_NEW = CardQueue(0)
QUEUE_TYPE_LRN = CardQueue(1)
QUEUE_TYPE_REV = CardQueue(2)
QUEUE_TYPE_DAY_LEARN_RELEARN = CardQueue(3)
QUEUE_TYPE_PREVIEW = CardQueue(4)
# Card types
CARD_TYPE_NEW = 0

View file

@ -98,7 +98,7 @@ class Scheduler(V2):
if card:
idx = self.countIdx(card)
if idx == QUEUE_TYPE_LRN:
counts[QUEUE_TYPE_LRN] += card.left // 1000
counts[int(QUEUE_TYPE_LRN)] += card.left // 1000
else:
counts[idx] += 1
@ -303,7 +303,8 @@ limit %d"""
card.odid = DeckID(0)
# if rescheduling is off, it needs to be set back to a new card
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")
def _startingLeft(self, card: Card) -> int:

View file

@ -805,7 +805,7 @@ limit ?"""
else:
card.queue = QUEUE_TYPE_DAY_LEARN_RELEARN
else:
card.queue = card.type
card.queue = CardQueue(card.type)
# Answering a review card
##########################################################################