mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
fix zerodiv and other errors
This commit is contained in:
parent
a856665824
commit
4be8b9d38c
2 changed files with 17 additions and 13 deletions
|
@ -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: <b>%s</b>") % ", ".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: <b>%s</b>") % ", ".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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue