mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -04:00
update cram for new cardActive() handling
This commit is contained in:
parent
cc8f619458
commit
c4a1f807ec
1 changed files with 14 additions and 18 deletions
32
anki/deck.py
32
anki/deck.py
|
@ -431,7 +431,6 @@ select count() from cards where type = 2 and combinedDue < :now
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
def setupCramScheduler(self, active, order):
|
def setupCramScheduler(self, active, order):
|
||||||
# need option to randomize
|
|
||||||
self.getCardId = self._getCramCardId
|
self.getCardId = self._getCramCardId
|
||||||
self.activeCramTags = active
|
self.activeCramTags = active
|
||||||
self.cramOrder = order
|
self.cramOrder = order
|
||||||
|
@ -467,10 +466,6 @@ select count() from cards where type = 2 and combinedDue < :now
|
||||||
return self.revQueue[-1][0]
|
return self.revQueue[-1][0]
|
||||||
if self.failedQueue:
|
if self.failedQueue:
|
||||||
return self.failedQueue[-1][0]
|
return self.failedQueue[-1][0]
|
||||||
if check:
|
|
||||||
# check for expired cards, or new day rollover
|
|
||||||
self.updateCutoff()
|
|
||||||
return self.getCardId(check=False)
|
|
||||||
# if we're in a custom scheduler, we may need to switch back
|
# if we're in a custom scheduler, we may need to switch back
|
||||||
if self.finishScheduler:
|
if self.finishScheduler:
|
||||||
self.finishScheduler()
|
self.finishScheduler()
|
||||||
|
@ -493,33 +488,34 @@ select count() from cards where type = 2 and combinedDue < :now
|
||||||
self.newCount = 0
|
self.newCount = 0
|
||||||
self.newCountToday = 0
|
self.newCountToday = 0
|
||||||
|
|
||||||
def _cramCardLimit(self, active):
|
def _cramCardLimit(self, active, sql):
|
||||||
if isinstance(active, list):
|
if isinstance(active, list):
|
||||||
return " and id in " + ids2str(active)
|
return sql.replace("where ", "where +c.id in " + ids2str(active))
|
||||||
else:
|
else:
|
||||||
yes = parseTags(active)
|
yes = parseTags(active)
|
||||||
if yes:
|
if yes:
|
||||||
yids = tagIds(self.s, yes).values()
|
yids = tagIds(self.s, yes).values()
|
||||||
return """
|
return sql.replace(
|
||||||
and id in (select cardId from cardTags where
|
"where ",
|
||||||
tagId in %s)""" % (ids2str(yids))
|
"where +c.id in (select cardId from cardTags where "
|
||||||
|
"tagId in %s) and " % ids2str(yids))
|
||||||
else:
|
else:
|
||||||
return ""
|
return sql
|
||||||
|
|
||||||
def _fillCramQueue(self):
|
def _fillCramQueue(self):
|
||||||
if self.revCount and not self.revQueue:
|
if self.revCount and not self.revQueue:
|
||||||
self.revQueue = self.s.all("""
|
self.revQueue = self.s.all(this.cardLimit(
|
||||||
|
self.activeCramTags, """
|
||||||
select id, factId from cards
|
select id, factId from cards
|
||||||
where type in (0,1,2) %s
|
where type in (0,1,2)
|
||||||
order by %s
|
order by %s
|
||||||
limit %s""" % (self._cramCardLimit(self.activeCramTags),
|
limit %s""" % (self.cramOrder, self.queueLimit)))
|
||||||
self.cramOrder, self.queueLimit))
|
|
||||||
self.revQueue.reverse()
|
self.revQueue.reverse()
|
||||||
|
|
||||||
def _rebuildCramCount(self):
|
def _rebuildCramCount(self):
|
||||||
self.revCount = self.s.scalar("""
|
self.revCount = self.s.scalar(this.cardLimit(
|
||||||
select count(*) from cards where type in (0,1,2) %s
|
self.activeCramTags,
|
||||||
""" % self._cramCardLimit(self.activeCramTags))
|
"select count(*) from cards where type in (0,1,2)"))
|
||||||
|
|
||||||
def _rebuildFailedCramCount(self):
|
def _rebuildFailedCramCount(self):
|
||||||
self.failedSoonCount = len(self.failedCramQueue)
|
self.failedSoonCount = len(self.failedCramQueue)
|
||||||
|
|
Loading…
Reference in a new issue