diff --git a/anki/stats.py b/anki/stats.py
index 6e95ecb0d..7238d211f 100644
--- a/anki/stats.py
+++ b/anki/stats.py
@@ -319,7 +319,7 @@ class DeckStats(object):
newP = new / float(total) * 100
youngP = young / float(total) * 100
oldP = old / float(total) * 100
- stats = d.getStats()
+ stats = {}
(stats["new"], stats["newP"]) = (new, newP)
(stats["old"], stats["oldP"]) = (old, oldP)
(stats["young"], stats["youngP"]) = (young, youngP)
@@ -339,19 +339,21 @@ class DeckStats(object):
html += "
"
html += "
"
html += "" + _("Correct Answers") + "
"
- html += _("Mature cards: ") + " " + fmtPerc(stats['gMatureYes%']) + (
+ (mAll, mYes, mPerc) = self.getMatureCorrect()
+ (yAll, yYes, yPerc) = self.getYoungCorrect()
+ (nAll, nYes, nPerc) = self.getNewCorrect()
+ html += _("Mature cards: ") + " " + fmtPerc(mPerc) + (
" " + _("(%(partOf)d of %(totalSum)d)") % {
- 'partOf' : stats['gMatureYes'],
- 'totalSum' : stats['gMatureTotal'] } + "
")
- html += _("Young cards: ") + " " + fmtPerc(stats['gYoungYes%']) + (
+ 'partOf' : mYes,
+ 'totalSum' : mAll } + "
")
+ html += _("Young cards: ") + " " + fmtPerc(yPerc) + (
" " + _("(%(partOf)d of %(totalSum)d)") % {
- 'partOf' : stats['gYoungYes'],
- 'totalSum' : stats['gYoungTotal'] } + "
")
- html += _("First-seen cards:") + " " + fmtPerc(stats['gNewYes%']) + (
+ 'partOf' : yYes,
+ 'totalSum' : yAll } + "
")
+ html += _("First-seen cards:") + " " + fmtPerc(nPerc) + (
" " + _("(%(partOf)d of %(totalSum)d)") % {
- 'partOf' : stats['gNewYes'],
- 'totalSum' : stats['gNewTotal'] } + "
")
-
+ 'partOf' : nYes,
+ 'totalSum' : nAll } + "
")
# average pending time
existing = d.cardCount - d.newCountToday
def tr(a, b):
@@ -466,6 +468,20 @@ class DeckStats(object):
html = runFilter("deckStats", html)
return html
+ def getMatureCorrect(self, test=None):
+ if not test:
+ test = "lastInterval > 21"
+ head = "select count() from reviewHistory where %s"
+ all = self.deck.s.scalar(head % test)
+ yes = self.deck.s.scalar((head % test) + " and ease > 1")
+ return (all, yes, yes/float(all)*100)
+
+ def getYoungCorrect(self):
+ return self.getMatureCorrect("lastInterval <= 21 and reps != 1")
+
+ def getNewCorrect(self):
+ return self.getMatureCorrect("reps = 1")
+
def getDaysReviewed(self, start, finish):
today = self.deck.failedCutoff
x = today + 86400*start