From e1a283b1683007ae22511ec4a40e5d3d38a490ce Mon Sep 17 00:00:00 2001 From: Arthur Milchior Date: Thu, 30 Jan 2020 18:04:59 -0800 Subject: [PATCH] REVLOG_RELRN --- pylib/anki/consts.py | 1 + pylib/anki/sched.py | 2 +- pylib/anki/schedv2.py | 2 +- pylib/anki/stats.py | 12 ++++++------ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pylib/anki/consts.py b/pylib/anki/consts.py index 22da0d552..2dc9962fc 100644 --- a/pylib/anki/consts.py +++ b/pylib/anki/consts.py @@ -72,6 +72,7 @@ BUTTON_FOUR = 4 # Revlog types REVLOG_LRN = 0 REVLOG_REV = 1 +REVLOG_RELRN = 2 # Labels ########################################################################## diff --git a/pylib/anki/sched.py b/pylib/anki/sched.py index 04b65ba4c..e277c06ce 100644 --- a/pylib/anki/sched.py +++ b/pylib/anki/sched.py @@ -558,7 +558,7 @@ did = ? and queue = 3 and due <= ? limit ?""", if card.odid and not card.wasNew: type = 3 elif card.type == 2: - type = 2 + type = REVLOG_RELRN else: type = REVLOG_LRN leaving = False diff --git a/pylib/anki/schedv2.py b/pylib/anki/schedv2.py index 12b64f923..f27552f90 100644 --- a/pylib/anki/schedv2.py +++ b/pylib/anki/schedv2.py @@ -608,7 +608,7 @@ did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN} and due <= ? limit ?""", def _answerLrnCard(self, card: Card, ease: int) -> None: conf = self._lrnConf(card) if card.type in (2, CARD_TYPE_RELEARNING): - type = 2 + type = REVLOG_RELRN else: type = REVLOG_LRN # lrnCount was decremented once when card was fetched diff --git a/pylib/anki/stats.py b/pylib/anki/stats.py index f606bef0e..fe3f1e3a2 100644 --- a/pylib/anki/stats.py +++ b/pylib/anki/stats.py @@ -155,7 +155,7 @@ select count(), sum(time)/1000, sum(case when ease = 1 then 1 else 0 end), /* failed */ sum(case when type = {REVLOG_LRN} then 1 else 0 end), /* learning */ sum(case when type = {REVLOG_REV} then 1 else 0 end), /* review */ -sum(case when type = 2 then 1 else 0 end), /* relearn */ +sum(case when type = {REVLOG_RELRN} then 1 else 0 end), /* relearn */ sum(case when type = 3 then 1 else 0 end) /* filter */ from revlog where id > ? """ + lim, @@ -551,13 +551,13 @@ select sum(case when type = {REVLOG_LRN} then 1 else 0 end), -- lrn count sum(case when type = {REVLOG_REV} and lastIvl < 21 then 1 else 0 end), -- yng count sum(case when type = {REVLOG_REV} and lastIvl >= 21 then 1 else 0 end), -- mtr count -sum(case when type = 2 then 1 else 0 end), -- lapse count +sum(case when type = {REVLOG_RELRN} then 1 else 0 end), -- lapse count sum(case when type = 3 then 1 else 0 end), -- cram count sum(case when type = {REVLOG_LRN} then time/1000.0 else 0 end)/:tf, -- lrn time -- yng + mtr time sum(case when type = {REVLOG_REV} and lastIvl < 21 then time/1000.0 else 0 end)/:tf, sum(case when type = {REVLOG_REV} and lastIvl >= 21 then time/1000.0 else 0 end)/:tf, -sum(case when type = 2 then time/1000.0 else 0 end)/:tf, -- lapse time +sum(case when type = {REVLOG_RELRN} then time/1000.0 else 0 end)/:tf, -- lapse time sum(case when type = 3 then time/1000.0 else 0 end)/:tf -- cram time from revlog %s group by day order by day""" @@ -758,10 +758,10 @@ select count(), avg(ivl), max(ivl) from cards where did in %s and queue = 2""" return self.col.db.all( f""" select (case -when type in ({REVLOG_LRN},2) then 0 +when type in ({REVLOG_LRN},{REVLOG_RELRN}) then 0 when lastIvl < 21 then 1 else 2 end) as thetype, -(case when type in ({REVLOG_LRN},2) and ease = 4 then %s else ease end), count() from revlog %s +(case when type in ({REVLOG_LRN},{REVLOG_RELRN}) and ease = 4 then %s else ease end), count() from revlog %s group by thetype, ease order by thetype, ease""" % (ease4repl, lim) @@ -856,7 +856,7 @@ select sum(case when ease = 1 then 0 else 1 end) / cast(count() as float) * 100, count() -from revlog where type in ({REVLOG_LRN},{REVLOG_REV},2) %s +from revlog where type in ({REVLOG_LRN},{REVLOG_REV},{REVLOG_RELRN}) %s group by hour having count() > 30 order by hour""" % lim, cut=self.col.sched.dayCutoff - (rolloverHour * 3600),