diff --git a/anki/graphs.py b/anki/graphs.py index 3364e11e2..11ba582b5 100644 --- a/anki/graphs.py +++ b/anki/graphs.py @@ -98,12 +98,15 @@ table * { font-size: 14px; } else: days = num*30 vals = [] - vals.append(_("%d/day") % (tot/days)) - if self.type > 0: - vals.append(_("%d/week") % (tot/(days/7))) - if self.type > 1: - vals.append(_("%d/month") % (tot/(days/30))) - txt = _("Average reviews: %s") % ", ".join(vals) + try: + vals.append(_("%d/day") % (tot/days)) + if self.type > 0: + vals.append(_("%d/week") % (tot/(days/7))) + if self.type > 1: + vals.append(_("%d/month") % (tot/(days/30))) + txt = _("Average reviews: %s") % ", ".join(vals) + except ZeroDivisionError: + return "" return txt def _due(self, start=None, end=None, chunk=1): @@ -367,9 +370,10 @@ where 1 """ + self._limit()) self._line(i, _("Total Cards"), c) self._line(i, _("Total Facts"), f) (low, avg, high) = self._factors() - self._line(i, _("Lowest ease factor"), "%d%%" % low) - self._line(i, _("Average ease factor"), "%d%%" % avg) - self._line(i, _("Highest ease factor"), "%d%%" % high) + if low: + self._line(i, _("Lowest ease factor"), "%d%%" % low) + self._line(i, _("Average ease factor"), "%d%%" % avg) + self._line(i, _("Highest ease factor"), "%d%%" % high) min = self.deck.db.scalar( "select min(crt) from cards where 1 " + self._limit()) if min: diff --git a/tests/test_sched.py b/tests/test_sched.py index 35ef0fd3f..ff8c7dbc0 100644 --- a/tests/test_sched.py +++ b/tests/test_sched.py @@ -598,7 +598,7 @@ def test_groupCounts(): # and one that's a child f = d.newFact() f['Front'] = u"two" - f.gid = d.groupId("Default Group::1") + f.gid = d.groupId("Default::1") d.addFact(f) # make it a review card c = f.cards()[0] @@ -619,12 +619,12 @@ def test_groupCounts(): assert d.sched.counts() == (3, 0, 1) assert len(d.groups()) == 4 cnts = d.sched.groupCounts() - assert cnts[0] == ["Default Group", 1, 1, 0, 1] - assert cnts[1] == ["Default Group::1", 2, 1, 1, 0] + assert cnts[0] == ["Default", 1, 1, 0, 1] + assert cnts[1] == ["Default::1", 2, 1, 1, 0] assert cnts[2] == ["foo::bar", 3, 1, 0, 1] assert cnts[3] == ["foo::baz", 4, 1, 0, 1] tree = d.sched.groupCountTree() - assert tree[0][0] == "Default Group" + assert tree[0][0] == "Default" # sum of child and parent assert tree[0][1] == 1 assert tree[0][2] == 2