diff --git a/pylib/anki/cards.py b/pylib/anki/cards.py index a94f271be..19845566a 100644 --- a/pylib/anki/cards.py +++ b/pylib/anki/cards.py @@ -48,8 +48,8 @@ class Card: self.id = timestampID(col.db, "cards") self.did = 1 self.crt = intTime() - self.type = 0 - self.queue = 0 + self.type = CARD_TYPE_NEW + self.queue = QUEUE_TYPE_NEW self.ivl = 0 self.factor = 0 self.reps = 0 diff --git a/pylib/anki/consts.py b/pylib/anki/consts.py index e9b1f37c7..f3d9fd1a9 100644 --- a/pylib/anki/consts.py +++ b/pylib/anki/consts.py @@ -14,7 +14,11 @@ NEW_CARDS_FIRST = 2 NEW_CARDS_RANDOM = 0 NEW_CARDS_DUE = 1 -# Card and queue types +# Queue types +QUEUE_TYPE_NEW = 0 + +# Card types +CARD_TYPE_NEW = 0 # removal types REM_CARD = 0 diff --git a/pylib/anki/find.py b/pylib/anki/find.py index ccd6844d3..57a66d03b 100644 --- a/pylib/anki/find.py +++ b/pylib/anki/find.py @@ -240,7 +240,7 @@ select distinct(n.id) from cards c, notes n where c.nid=n.id and """ elif type == "cardDue": sort = "c.type, c.due" elif type == "cardEase": - sort = "c.type == 0, c.factor" + sort = f"c.type == {CARD_TYPE_NEW}, c.factor" elif type == "cardLapses": sort = "c.lapses" elif type == "cardIvl": @@ -271,7 +271,7 @@ select distinct(n.id) from cards c, notes n where c.nid=n.id and """ if val == "review": n = 2 elif val == "new": - n = 0 + n = CARD_TYPE_NEW else: return "queue in (1, 3)" return "type = %d" % n diff --git a/pylib/anki/importing/anki2.py b/pylib/anki/importing/anki2.py index 46d54000c..ee681d570 100644 --- a/pylib/anki/importing/anki2.py +++ b/pylib/anki/importing/anki2.py @@ -6,6 +6,7 @@ import unicodedata from typing import Any, Dict, List, Optional, Tuple from anki.collection import _Collection +from anki.consts import * from anki.importing.base import Importer from anki.lang import _ from anki.storage import Collection @@ -357,12 +358,12 @@ class Anki2Importer(Importer): card[14] = 0 # queue if card[6] == 1: # type - card[7] = 0 + card[7] = QUEUE_TYPE_NEW else: card[7] = card[6] # type if card[6] == 1: - card[6] = 0 + card[6] = CARD_TYPE_NEW cards.append(card) # we need to import revlog, rewriting card ids and bumping usn for rev in self.src.db.execute("select * from revlog where cid = ?", scid): diff --git a/pylib/anki/sched.py b/pylib/anki/sched.py index 06b039c11..2bf2fbafb 100644 --- a/pylib/anki/sched.py +++ b/pylib/anki/sched.py @@ -67,13 +67,13 @@ class Scheduler: self._burySiblings(card) card.reps += 1 # former is for logging new cards, latter also covers filt. decks - card.wasNew = card.type == 0 - wasNewQ = card.queue == 0 + card.wasNew = card.type == CARD_TYPE_NEW + wasNewQ = card.queue == QUEUE_TYPE_NEW if wasNewQ: # came from the new queue, move to learning card.queue = 1 # if it was a new card, it's now a learning card - if card.type == 0: + if card.type == CARD_TYPE_NEW: card.type = 1 # init reps to graduation card.left = self._startingLeft(card) @@ -142,7 +142,7 @@ order by due""" if card.odid and card.queue == 2: return 4 conf = self._lrnConf(card) - if card.type in (0, 1) or len(conf["delays"]) > 1: + if card.type in (CARD_TYPE_NEW, 1) or len(conf["delays"]) > 1: return 3 return 2 elif card.queue == 2: @@ -348,9 +348,9 @@ order by due""" def _resetNewCount(self): cntFn = lambda did, lim: self.col.db.scalar( - """ + f""" select count() from (select 1 from cards where -did = ? and queue = 0 limit ?)""", +did = ? and queue = {QUEUE_TYPE_NEW} limit ?)""", did, lim, ) @@ -373,8 +373,8 @@ did = ? and queue = 0 limit ?)""", if lim: # fill the queue with the current did self._newQueue = self.col.db.list( - """ - select id from cards where did = ? and queue = 0 order by due,ord limit ?""", + f""" + select id from cards where did = ? and queue = {QUEUE_TYPE_NEW} order by due,ord limit ?""", did, lim, ) @@ -436,9 +436,9 @@ did = ? and queue = 0 limit ?)""", return 0 lim = min(lim, self.reportLimit) return self.col.db.scalar( - """ + f""" select count() from -(select 1 from cards where did = ? and queue = 0 limit ?)""", +(select 1 from cards where did = ? and queue = {QUEUE_TYPE_NEW} limit ?)""", did, lim, ) @@ -452,9 +452,9 @@ select count() from def totalNewForCurrentDeck(self): return self.col.db.scalar( - """ + f""" select count() from cards where id in ( -select id from cards where did in %s and queue = 0 limit ?)""" +select id from cards where did in %s and queue = {QUEUE_TYPE_NEW} limit ?)""" % ids2str(self.col.decks.active()), self.reportLimit, ) @@ -652,7 +652,7 @@ did = ? and queue = 3 and due <= ? limit ?""", card.odid = 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 = 0 + card.queue = card.type = CARD_TYPE_NEW card.due = self.col.nextID("pos") def _startingLeft(self, card): @@ -1058,9 +1058,9 @@ select id from cards where did in %s and queue = 2 and due <= ? limit ?)""" self.col.log(self.col.db.list("select id from cards where %s" % lim)) # move out of cram queue self.col.db.execute( - """ -update cards set did = odid, queue = (case when type = 1 then 0 -else type end), type = (case when type = 1 then 0 else type end), + f""" +update cards set did = odid, queue = (case when type = 1 then {QUEUE_TYPE_NEW} +else type end), type = (case when type = 1 then {CARD_TYPE_NEW} else type end), due = odue, odue = 0, odid = 0, usn = ? where %s""" % lim, self.col.usn(), @@ -1106,9 +1106,9 @@ due = odue, odue = 0, odid = 0, usn = ? where %s""" data.append((did, -100000 + c, u, id)) # due reviews stay in the review queue. careful: can't use # "odid or did", as sqlite converts to boolean - queue = """ + queue = f""" (case when type=2 and (case when odue then odue <= %d else due <= %d end) - then 2 else 0 end)""" + then 2 else {QUEUE_TYPE_NEW} end)""" queue %= (self.today, self.today) self.col.db.executemany( """ @@ -1321,7 +1321,7 @@ To study outside of the normal schedule, click the Custom Study button below.""" def newDue(self): "True if there are any new cards due." return self.col.db.scalar( - ("select 1 from cards where did in %s and queue = 0 " "limit 1") + (f"select 1 from cards where did in %s and queue = {QUEUE_TYPE_NEW} " "limit 1") % self._deckLimit() ) @@ -1347,7 +1347,7 @@ To study outside of the normal schedule, click the Custom Study button below.""" def nextIvl(self, card, ease): "Return the next interval for CARD, in seconds." - if card.queue in (0, 1, 3): + if card.queue in (QUEUE_TYPE_NEW, 1, 3): return self._nextLrnIvl(card, ease) elif ease == BUTTON_ONE: # lapsed @@ -1436,9 +1436,9 @@ update cards set queue=-2,mod=?,usn=? where id in """ buryRev = rconf.get("bury", True) # loop through and remove from queues for cid, queue in self.col.db.execute( - """ + f""" select id, queue from cards where nid=? and id!=? -and (queue=0 or (queue=2 and due<=?))""", +and (queue={QUEUE_TYPE_NEW} or (queue=2 and due<=?))""", card.nid, card.id, self.today, @@ -1475,11 +1475,11 @@ and (queue=0 or (queue=2 and due<=?))""", "Put cards at the end of the new queue." self.remFromDyn(ids) self.col.db.execute( - "update cards set type=0,queue=0,ivl=0,due=0,odue=0,factor=?" + f"update cards set type={CARD_TYPE_NEW},queue={QUEUE_TYPE_NEW},ivl=0,due=0,odue=0,factor=?" " where id in " + ids2str(ids), STARTING_FACTOR, ) - pmax = self.col.db.scalar("select max(due) from cards where type=0") or 0 + pmax = self.col.db.scalar(f"select max(due) from cards where type={CARD_TYPE_NEW}") or 0 # takes care of mod + usn self.sortCards(ids, start=pmax + 1) self.col.log(ids) @@ -1515,11 +1515,11 @@ usn=:usn,mod=:mod,factor=:fact where id=:id""", sids = ids2str(ids) # we want to avoid resetting due number of existing new cards on export nonNew = self.col.db.list( - "select id from cards where id in %s and (queue != 0 or type != 0)" % sids + f"select id from cards where id in %s and (queue != {QUEUE_TYPE_NEW} or type != {CARD_TYPE_NEW})" % sids ) # reset all cards self.col.db.execute( - "update cards set reps=0,lapses=0,odid=0,odue=0,queue=0" + f"update cards set reps=0,lapses=0,odid=0,odue=0,queue={QUEUE_TYPE_NEW}" " where id in %s" % sids ) # and forget any non-new cards, changing their due numbers @@ -1553,16 +1553,16 @@ usn=:usn,mod=:mod,factor=:fact where id=:id""", # shift? if shift: low = self.col.db.scalar( - "select min(due) from cards where due >= ? and type = 0 " + f"select min(due) from cards where due >= ? and type = {CARD_TYPE_NEW} " "and id not in %s" % scids, start, ) if low is not None: shiftby = high - low + 1 self.col.db.execute( - """ + f""" update cards set mod=?, usn=?, due=due+? where id not in %s -and due >= ? and queue = 0""" +and due >= ? and queue = {QUEUE_TYPE_NEW}""" % scids, now, self.col.usn(), @@ -1572,7 +1572,7 @@ and due >= ? and queue = 0""" # reorder cards d = [] for id, nid in self.col.db.execute( - "select id, nid from cards where type = 0 and id in " + scids + f"select id, nid from cards where type = {CARD_TYPE_NEW} and id in " + scids ): d.append(dict(now=now, due=due[nid], usn=self.col.usn(), cid=id)) self.col.db.executemany( diff --git a/pylib/anki/schedv2.py b/pylib/anki/schedv2.py index 72a73f020..8c1d1e2fe 100644 --- a/pylib/anki/schedv2.py +++ b/pylib/anki/schedv2.py @@ -95,7 +95,7 @@ class Scheduler: card.reps += 1 - if card.queue == 0: + if card.queue == QUEUE_TYPE_NEW: # came from the new queue, move to learning card.queue = 1 card.type = 1 @@ -369,9 +369,9 @@ order by due""" def _resetNewCount(self) -> None: cntFn = lambda did, lim: self.col.db.scalar( - """ + f""" select count() from (select 1 from cards where -did = ? and queue = 0 limit ?)""", +did = ? and queue = {QUEUE_TYPE_NEW} limit ?)""", did, lim, ) @@ -394,8 +394,8 @@ did = ? and queue = 0 limit ?)""", if lim: # fill the queue with the current did self._newQueue = self.col.db.list( - """ - select id from cards where did = ? and queue = 0 order by due,ord limit ?""", + f""" + select id from cards where did = ? and queue = {QUEUE_TYPE_NEW} order by due,ord limit ?""", did, lim, ) @@ -463,9 +463,9 @@ did = ? and queue = 0 limit ?)""", return 0 lim = min(lim, self.reportLimit) return self.col.db.scalar( - """ + f""" select count() from -(select 1 from cards where did = ? and queue = 0 limit ?)""", +(select 1 from cards where did = ? and queue = {QUEUE_TYPE_NEW} limit ?)""", did, lim, ) @@ -479,9 +479,9 @@ select count() from def totalNewForCurrentDeck(self) -> Any: return self.col.db.scalar( - """ + f""" select count() from cards where id in ( -select id from cards where did in %s and queue = 0 limit ?)""" +select id from cards where did in %s and queue = {QUEUE_TYPE_NEW} limit ?)""" % self._deckLimit(), self.reportLimit, ) @@ -1520,7 +1520,7 @@ To study outside of the normal schedule, click the Custom Study button below.""" def newDue(self) -> Any: "True if there are any new cards due." return self.col.db.scalar( - ("select 1 from cards where did in %s and queue = 0 " "limit 1") + (f"select 1 from cards where did in %s and queue = {QUEUE_TYPE_NEW} " "limit 1") % self._deckLimit() ) @@ -1563,7 +1563,7 @@ To study outside of the normal schedule, click the Custom Study button below.""" return 0 # (re)learning? - if card.queue in (0, 1, QUEUE_TYPE_DAY_LEARN_RELEARN): + if card.queue in (QUEUE_TYPE_NEW, 1, QUEUE_TYPE_DAY_LEARN_RELEARN): return self._nextLrnIvl(card, ease) elif ease == BUTTON_ONE: # lapse @@ -1581,7 +1581,7 @@ To study outside of the normal schedule, click the Custom Study button below.""" # this isn't easily extracted from the learn code def _nextLrnIvl(self, card: Card, ease: int) -> Any: - if card.queue == 0: + if card.queue == QUEUE_TYPE_NEW: card.left = self._startingLeft(card) conf = self._lrnConf(card) if ease == BUTTON_ONE: @@ -1647,7 +1647,7 @@ update cards set queue=?,mod=?,usn=? where id in """ def buryNote(self, nid) -> None: "Bury all cards for note until next session." cids = self.col.db.list( - "select id from cards where nid = ? and queue >= 0", nid + f"select id from cards where nid = ? and queue >= {QUEUE_TYPE_NEW}", nid ) self.buryCards(cids) @@ -1699,9 +1699,9 @@ update cards set queue=?,mod=?,usn=? where id in """ buryRev = rconf.get("bury", True) # loop through and remove from queues for cid, queue in self.col.db.execute( - """ + f""" select id, queue from cards where nid=? and id!=? -and (queue=0 or (queue=2 and due<=?))""", +and (queue={QUEUE_TYPE_NEW} or (queue=2 and due<=?))""", card.nid, card.id, self.today, @@ -1733,11 +1733,11 @@ and (queue=0 or (queue=2 and due<=?))""", "Put cards at the end of the new queue." self.remFromDyn(ids) self.col.db.execute( - "update cards set type=0,queue=0,ivl=0,due=0,odue=0,factor=?" + f"update cards set type={CARD_TYPE_NEW},queue={QUEUE_TYPE_NEW},ivl=0,due=0,odue=0,factor=?" " where id in " + ids2str(ids), STARTING_FACTOR, ) - pmax = self.col.db.scalar("select max(due) from cards where type=0") or 0 + pmax = self.col.db.scalar(f"select max(due) from cards where type={CARD_TYPE_NEW}") or 0 # takes care of mod + usn self.sortCards(ids, start=pmax + 1) self.col.log(ids) @@ -1773,11 +1773,11 @@ usn=:usn,mod=:mod,factor=:fact where id=:id""", sids = ids2str(ids) # we want to avoid resetting due number of existing new cards on export nonNew = self.col.db.list( - "select id from cards where id in %s and (queue != 0 or type != 0)" % sids + f"select id from cards where id in %s and (queue != {QUEUE_TYPE_NEW} or type != {CARD_TYPE_NEW})" % sids ) # reset all cards self.col.db.execute( - "update cards set reps=0,lapses=0,odid=0,odue=0,queue=0" + f"update cards set reps=0,lapses=0,odid=0,odue=0,queue={QUEUE_TYPE_NEW}" " where id in %s" % sids ) # and forget any non-new cards, changing their due numbers @@ -1818,16 +1818,16 @@ usn=:usn,mod=:mod,factor=:fact where id=:id""", # shift? if shift: low = self.col.db.scalar( - "select min(due) from cards where due >= ? and type = 0 " + f"select min(due) from cards where due >= ? and type = {CARD_TYPE_NEW} " "and id not in %s" % scids, start, ) if low is not None: shiftby = high - low + 1 self.col.db.execute( - """ + f""" update cards set mod=?, usn=?, due=due+? where id not in %s -and due >= ? and queue = 0""" +and due >= ? and queue = {QUEUE_TYPE_NEW}""" % scids, now, self.col.usn(), @@ -1837,7 +1837,7 @@ and due >= ? and queue = 0""" # reorder cards d = [] for id, nid in self.col.db.execute( - "select id, nid from cards where type = 0 and id in " + scids + f"select id, nid from cards where type = {CARD_TYPE_NEW} and id in " + scids ): d.append(dict(now=now, due=due[nid], usn=self.col.usn(), cid=id)) self.col.db.executemany( @@ -1875,10 +1875,10 @@ and due >= ? and queue = 0""" self.col.db.execute( f""" update cards set did = odid, queue = (case -when type = 1 then 0 +when type = 1 then {QUEUE_TYPE_NEW} when type = {CARD_TYPE_RELEARNING} then 2 else type end), type = (case -when type = 1 then 0 +when type = 1 then {CARD_TYPE_NEW} when type = {CARD_TYPE_RELEARNING} then 2 else type end), due = odue, odue = 0, odid = 0, usn = ? where odid != 0""", @@ -1917,13 +1917,13 @@ due = odue, odue = 0, odid = 0, usn = ? where odid != 0""", self.col.db.execute( f""" update cards set type = (case -when type = 1 then 0 +when type = 1 then {CARD_TYPE_NEW} when type in (2, {CARD_TYPE_RELEARNING}) then 2 else type end), due = (case when odue then odue else due end), odue = 0, mod = %d, usn = %d -where queue < 0""" +where queue < {QUEUE_TYPE_NEW}""" % (intTime(), self.col.usn()) ) @@ -1937,7 +1937,7 @@ where queue < 0""" # adding 'hard' in v2 scheduler means old ease entries need shifting # up or down def _remapLearningAnswers(self, sql: str) -> None: - self.col.db.execute("update revlog set %s and type in (0,2)" % sql) + self.col.db.execute(f"update revlog set %s and type in ({CARD_TYPE_NEW},2)" % sql) def moveToV1(self) -> None: self._emptyAllFiltered() diff --git a/pylib/anki/stats.py b/pylib/anki/stats.py index b855ee7bb..32e24341a 100644 --- a/pylib/anki/stats.py +++ b/pylib/anki/stats.py @@ -36,7 +36,7 @@ class CardStats: self.addLine(_("First Review"), self.date(first / 1000)) self.addLine(_("Latest Review"), self.date(last / 1000)) if c.type in (1, 2): - if c.odid or c.queue < 0: + if c.odid or c.queue < QUEUE_TYPE_NEW: next = None else: if c.queue in (2, 3): @@ -57,7 +57,7 @@ class CardStats: if cnt: self.addLine(_("Average Time"), self.time(total / float(cnt))) self.addLine(_("Total Time"), self.time(total)) - elif c.queue == 0: + elif c.queue == QUEUE_TYPE_NEW: self.addLine(_("Position"), c.due) self.addLine(_("Card Type"), c.template()["name"]) self.addLine(_("Note Type"), c.model()["name"]) @@ -941,12 +941,12 @@ from cards where did in %s and queue = 2""" def _cards(self) -> Any: return self.col.db.first( - """ + f""" select sum(case when queue=2 and ivl >= 21 then 1 else 0 end), -- mtr sum(case when queue in (1,3) or (queue=2 and ivl < 21) then 1 else 0 end), -- yng/lrn -sum(case when queue=0 then 1 else 0 end), -- new -sum(case when queue<0 then 1 else 0 end) -- susp +sum(case when queue={QUEUE_TYPE_NEW} then 1 else 0 end), -- new +sum(case when queue<{QUEUE_TYPE_NEW} then 1 else 0 end) -- susp from cards where did in %s""" % self._limit() ) diff --git a/pylib/tests/test_schedv1.py b/pylib/tests/test_schedv1.py index bd5de3f08..186637340 100644 --- a/pylib/tests/test_schedv1.py +++ b/pylib/tests/test_schedv1.py @@ -4,7 +4,7 @@ import copy import time from anki import hooks -from anki.consts import STARTING_FACTOR +from anki.consts import * from anki.utils import intTime from tests.shared import getEmptyCol as getEmptyColOrig @@ -46,8 +46,8 @@ def test_new(): # fetch it c = d.sched.getCard() assert c - assert c.queue == 0 - assert c.type == 0 + assert c.queue == QUEUE_TYPE_NEW + assert c.type == CARD_TYPE_NEW # if we answer it, it should become a learn card t = intTime() d.sched.answerCard(c, 1) @@ -707,7 +707,7 @@ def test_cram_rem(): # if we terminate cramming prematurely it should be set back to new d.sched.emptyDyn(did) c.load() - assert c.type == c.queue == 0 + assert c.type == CARD_TYPE_NEW and c.queue == QUEUE_TYPE_NEW assert c.due == oldDue @@ -731,7 +731,7 @@ def test_cram_resched(): assert ni(c, 3) == 0 assert d.sched.nextIvlStr(c, 3) == "(end)" d.sched.answerCard(c, 3) - assert c.queue == c.type == 0 + assert c.type == CARD_TYPE_NEW and c.queue == QUEUE_TYPE_NEW # undue reviews should also be unaffected c.ivl = 100 c.type = c.queue = 2 diff --git a/pylib/tests/test_schedv2.py b/pylib/tests/test_schedv2.py index 2f3865ff5..be4cfa144 100644 --- a/pylib/tests/test_schedv2.py +++ b/pylib/tests/test_schedv2.py @@ -4,7 +4,7 @@ import copy import time from anki import hooks -from anki.consts import STARTING_FACTOR +from anki.consts import * from anki.utils import intTime from tests.shared import getEmptyCol as getEmptyColOrig @@ -57,8 +57,8 @@ def test_new(): # fetch it c = d.sched.getCard() assert c - assert c.queue == 0 - assert c.type == 0 + assert c.queue == QUEUE_TYPE_NEW + assert c.type == CARD_TYPE_NEW # if we answer it, it should become a learn card t = intTime() d.sched.answerCard(c, 1) @@ -634,7 +634,7 @@ def test_bury(): d.sched.unburyCardsForDeck(type="manual") # pylint: disable=unexpected-keyword-arg c.load() - assert c.queue == 0 + assert c.queue == QUEUE_TYPE_NEW c2.load() assert c2.queue == -2 @@ -642,7 +642,7 @@ def test_bury(): type="siblings" ) c2.load() - assert c2.queue == 0 + assert c2.queue == QUEUE_TYPE_NEW d.sched.buryCards([c.id, c2.id]) d.sched.unburyCardsForDeck(type="all") # pylint: disable=unexpected-keyword-arg @@ -833,9 +833,9 @@ def test_preview(): # passing it will remove it d.sched.answerCard(c2, 2) - assert c2.queue == 0 + assert c2.queue == QUEUE_TYPE_NEW assert c2.reps == 0 - assert c2.type == 0 + assert c2.type == CARD_TYPE_NEW # the other card should appear again c = d.sched.getCard() @@ -844,9 +844,9 @@ def test_preview(): # emptying the filtered deck should restore card d.sched.emptyDyn(did) c.load() - assert c.queue == 0 + assert c.queue == QUEUE_TYPE_NEW assert c.reps == 0 - assert c.type == 0 + assert c.type == CARD_TYPE_NEW def test_ordcycle(): @@ -1217,8 +1217,8 @@ def test_moveVersions(): # the move to v2 should reset it to new col.changeSchedulerVer(2) c.load() - assert c.queue == 0 - assert c.type == 0 + assert c.queue == QUEUE_TYPE_NEW + assert c.type == CARD_TYPE_NEW # fail it again, and manually bury it col.reset() @@ -1238,7 +1238,7 @@ def test_moveVersions(): # and it should be new again when unburied col.sched.unburyCards() c.load() - assert c.queue == c.type == 0 + assert c.type == CARD_TYPE_NEW and c.queue == QUEUE_TYPE_NEW # make sure relearning cards transition correctly to v1 col.changeSchedulerVer(2) diff --git a/pylib/tests/test_undo.py b/pylib/tests/test_undo.py index d37a8baa6..a4a8a7098 100644 --- a/pylib/tests/test_undo.py +++ b/pylib/tests/test_undo.py @@ -55,7 +55,7 @@ def test_review(): # answer assert d.sched.counts() == (1, 0, 0) c = d.sched.getCard() - assert c.queue == 0 + assert c.queue == QUEUE_TYPE_NEW d.sched.answerCard(c, 3) assert c.left == 1001 assert d.sched.counts() == (0, 1, 0) @@ -66,7 +66,7 @@ def test_review(): d.reset() assert d.sched.counts() == (1, 0, 0) c.load() - assert c.queue == 0 + assert c.queue == QUEUE_TYPE_NEW assert c.left != 1001 assert not d.undoName() # we should be able to undo multiple answers too diff --git a/qt/aqt/browser.py b/qt/aqt/browser.py index 6080dab34..77af12b3f 100644 --- a/qt/aqt/browser.py +++ b/qt/aqt/browser.py @@ -335,7 +335,7 @@ class DataModel(QAbstractTableModel): return _("(filtered)") elif c.queue == 1: date = c.due - elif c.queue == 0 or c.type == 0: + elif c.queue == QUEUE_TYPE_NEW or c.type == CARD_TYPE_NEW: return str(c.due) elif c.queue in (2, 3) or (c.type == 2 and c.queue < 0): date = time.time() + ((c.due - self.col.sched.today) * 86400) @@ -1428,7 +1428,7 @@ border: 1px solid #000; padding: 3px; '>%s""" import anki.stats as st fmt = "%s" - if type == 0: + if type == CARD_TYPE_NEW: tstr = fmt % (st.colLearn, tstr) elif type == 1: tstr = fmt % (st.colMature, tstr) @@ -1936,7 +1936,7 @@ update cards set usn=?, mod=?, did=? where id in """ def _reposition(self): cids = self.selectedCards() cids2 = self.col.db.list( - "select id from cards where type = 0 and id in " + ids2str(cids) + f"select id from cards where type = {CARD_TYPE_NEW} and id in " + ids2str(cids) ) if not cids2: return showInfo(_("Only new cards can be repositioned.")) @@ -1945,7 +1945,7 @@ update cards set usn=?, mod=?, did=? where id in """ frm = aqt.forms.reposition.Ui_Dialog() frm.setupUi(d) (pmin, pmax) = self.col.db.first( - "select min(due), max(due) from cards where type=0 and odid=0" + f"select min(due), max(due) from cards where type={CARD_TYPE_NEW} and odid=0" ) pmin = pmin or 0 pmax = pmax or 0