Merge pull request #401 from agentydragon/sched-types

Use self._deckLimit helper in more places in scheduler v2
This commit is contained in:
Damien Elmes 2019-12-28 07:12:58 +10:00 committed by GitHub
commit 729330324e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -474,7 +474,7 @@ select count() from
""" """
select count() from cards where id in ( 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 = 0 limit ?)"""
% ids2str(self.col.decks.active()), % self._deckLimit(),
self.reportLimit, self.reportLimit,
) )
@ -884,9 +884,10 @@ and due <= ? limit ?)"""
self.revCount = self.col.db.scalar( self.revCount = self.col.db.scalar(
""" """
select count() from (select id from cards where select count() from (select id from cards where
did in %s and queue = 2 and due <= ? limit %d)""" did in %s and queue = 2 and due <= ? limit ?)"""
% (ids2str(self.col.decks.active()), lim), % self._deckLimit(),
self.today, self.today,
lim,
) )
def _resetRev(self) -> None: def _resetRev(self) -> None:
@ -907,7 +908,7 @@ select id from cards where
did in %s and queue = 2 and due <= ? did in %s and queue = 2 and due <= ?
order by due, random() order by due, random()
limit ?""" limit ?"""
% (ids2str(self.col.decks.active())), % self._deckLimit(),
self.today, self.today,
lim, lim,
) )
@ -935,7 +936,7 @@ limit ?"""
""" """
select count() from cards where id in ( select count() from cards where id in (
select id from cards where did in %s and queue = 2 and due <= ? limit ?)""" select id from cards where did in %s and queue = 2 and due <= ? limit ?)"""
% ids2str(self.col.decks.active()), % self._deckLimit(),
self.today, self.today,
self.reportLimit, self.reportLimit,
) )
@ -1478,16 +1479,16 @@ To study outside of the normal schedule, click the Custom Study button below."""
) )
def haveBuriedSiblings(self) -> bool: def haveBuriedSiblings(self) -> bool:
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 "select 1 from cards where queue = -2 and did in %s limit 1"
% self._deckLimit()
) )
return not not cnt return not not cnt
def haveManuallyBuried(self) -> bool: def haveManuallyBuried(self) -> bool:
sdids = ids2str(self.col.decks.active())
cnt = self.col.db.scalar( cnt = self.col.db.scalar(
"select 1 from cards where queue = -3 and did in %s limit 1" % sdids "select 1 from cards where queue = -3 and did in %s limit 1"
% self._deckLimit()
) )
return not not cnt return not not cnt
@ -1620,15 +1621,15 @@ update cards set queue=?,mod=?,usn=? where id in """
else: else:
raise Exception("unknown type") raise Exception("unknown type")
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 %s and did in %s" % (queue, sids) "select id from cards where %s and did in %s"
% (queue, self._deckLimit())
) )
) )
self.col.db.execute( self.col.db.execute(
"update cards set mod=?,usn=?,%s where %s and did in %s" "update cards set mod=?,usn=?,%s where %s and did in %s"
% (self._restoreQueueSnippet, queue, sids), % (self._restoreQueueSnippet, queue, self._deckLimit()),
intTime(), intTime(),
self.col.usn(), self.col.usn(),
) )