From dac46752edd9a060ebb1682196a99bad856bcd33 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 18 Sep 2011 09:42:04 +0900 Subject: [PATCH] drop the count_answered option --- anki/deck.py | 1 - anki/sched.py | 12 +----------- tests/test_sched.py | 43 ------------------------------------------- 3 files changed, 1 insertion(+), 55 deletions(-) diff --git a/anki/deck.py b/anki/deck.py index 2aaaa0ad1..c9353026d 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -24,7 +24,6 @@ defaultConf = { 'topGroup': 1, 'curGroup': None, 'revOrder': REV_CARDS_RANDOM, - 'counts': COUNT_REMAINING, # other config 'nextPos': 1, 'fontFamilies': [ diff --git a/anki/sched.py b/anki/sched.py index ad5f3076e..6129bcced 100644 --- a/anki/sched.py +++ b/anki/sched.py @@ -67,18 +67,8 @@ class Scheduler(object): def counts(self): "Does not include fetched but unanswered." - if self.deck.conf['counts'] == COUNT_REMAINING: - return self.dueCounts() - else: - return self.answeredCounts() - - def dueCounts(self): return (self.newCount, self.lrnCount, self.revCount) - def answeredCounts(self): - t = self.deck.groups.top() - return (t['newToday'][1], t['lrnToday'][1], t['revToday'][1]) - def dueForecast(self, days=7): "Return counts over next DAYS. Includes today." daysd = dict(self.deck.db.all(""" @@ -740,7 +730,7 @@ queue = 2 %s and due <= :lim order by %s limit %d""" % ( def repsToday(self): "Number of cards answered today." - return sum(self.answeredCounts()) + return sum(self.counts()) # Dynamic indices ########################################################################## diff --git a/tests/test_sched.py b/tests/test_sched.py index df57b299a..873aa034f 100644 --- a/tests/test_sched.py +++ b/tests/test_sched.py @@ -586,48 +586,8 @@ def test_ordcycle(): assert d.sched.getCard().ord == 1 assert d.sched.getCard().ord == 2 -def test_counts_up(): - d = getEmptyDeck() - d.conf['counts'] = COUNT_ANSWERED - # for each card type - for type in range(3): - # create a new fact - f = d.newFact() - f['Front'] = u"one" - d.addFact(f) - c = f.cards()[0] - # set type/gid - c.type = type - c.queue = type - c.due = 0 - c.flush() - d.reset() - # all zeros first - assert d.sched.counts() == (0,0,0) - # answer the first card, which is a lrn one - c = d.sched.getCard() - assert c.queue == 1 - d.sched.answerCard(c, 4) - assert d.sched.counts() == (0,1,0) - # and the next, which is a rev card - c = d.sched.getCard() - assert c.queue == 2 - d.sched.answerCard(c, 4) - assert d.sched.counts() == (0,1,1) - # and the last, which is a new one - c = d.sched.getCard() - assert c.queue == 0 - d.sched.answerCard(c, 4) - assert d.sched.counts() == (1,1,1) - # total should match - assert d.sched.repsToday() == 3 - # the time should have been updated as well, but it gets rounded to zero - # in the test so we need to grab it manually - assert d.groups.top()['timeToday'][1] - def test_counts_down(): d = getEmptyDeck() - d.conf['counts'] = COUNT_REMAINING # add a second group grp = d.groups.id("new group") # for each card type @@ -655,7 +615,6 @@ def test_counts_down(): def test_counts_idx(): d = getEmptyDeck() - d.conf['counts'] = COUNT_REMAINING f = d.newFact() f['Front'] = u"one"; f['Back'] = u"two" d.addFact(f) @@ -718,7 +677,6 @@ def test_collapse(): def test_groupCounts(): d = getEmptyDeck() - d.conf['counts'] = COUNT_REMAINING # add a fact with default group f = d.newFact() f['Front'] = u"one" @@ -808,7 +766,6 @@ def test_reorder(): def test_forget(): d = getEmptyDeck() - d.conf['counts'] = COUNT_REMAINING f = d.newFact() f['Front'] = u"one" d.addFact(f)