make sure cramming works if there are no selected groups

This commit is contained in:
Damien Elmes 2011-03-24 09:52:14 +09:00
parent 31427f0133
commit 464eb2b684
2 changed files with 12 additions and 5 deletions

View file

@ -62,14 +62,18 @@ class CramScheduler(Scheduler):
maxlim = "and due <= %d" % (self.today+1+self.max)
else:
maxlim = ""
if self.gids:
extra = "and gid in "+ids2str(self.gids)
else:
extra = ""
self.newQueue = self.db.list("""
select id from cards where queue = 2 and due >= %d
%s
and gid in %s order by %s limit %d""" % (self.today+1+self.min,
maxlim,
ids2str(self.gids),
self.order,
self.reportLimit))
%s order by %s limit %d""" % (self.today+1+self.min,
maxlim,
extra,
self.order,
self.reportLimit))
self.newCount = len(self.newQueue)
def _resetRev(self):

View file

@ -383,6 +383,9 @@ def test_cram():
d.sched.answerCard(c, 3)
assert c.ivl == 1
assert c.due == d.sched.today + 1
# users should be able to cram entire deck too
d.cramGroups([])
assert d.sched.counts()[0] > 0
def test_cramLimits():
d = getEmptyDeck()