REVLOG_LRN

This commit is contained in:
Arthur Milchior 2020-01-30 18:03:11 -08:00
parent dd258ca62c
commit dca1cd03d1
4 changed files with 14 additions and 12 deletions

View file

@ -70,6 +70,7 @@ BUTTON_THREE = 3
BUTTON_FOUR = 4
# Revlog types
REVLOG_LRN = 0
# Labels
##########################################################################

View file

@ -560,7 +560,7 @@ did = ? and queue = 3 and due <= ? limit ?""",
elif card.type == 2:
type = 2
else:
type = 0
type = REVLOG_LRN
leaving = False
# lrnCount was decremented once when card was fetched
lastLeft = card.left

View file

@ -610,7 +610,7 @@ did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN} and due <= ? limit ?""",
if card.type in (2, CARD_TYPE_RELEARNING):
type = 2
else:
type = 0
type = REVLOG_LRN
# lrnCount was decremented once when card was fetched
lastLeft = card.left

View file

@ -6,6 +6,7 @@ import json
import time
from typing import Any, Dict, List, Optional, Tuple
from anki.consts import *
from anki.lang import _, ngettext
from anki.utils import fmtTimeSpan, ids2str
@ -149,10 +150,10 @@ body {background-image: url(data:image/png;base64,%s); }
if lim:
lim = " and " + lim
cards, thetime, failed, lrn, rev, relrn, filt = self.col.db.first(
"""
f"""
select count(), sum(time)/1000,
sum(case when ease = 1 then 1 else 0 end), /* failed */
sum(case when type = 0 then 1 else 0 end), /* learning */
sum(case when type = {REVLOG_LRN} then 1 else 0 end), /* learning */
sum(case when type = 1 then 1 else 0 end), /* review */
sum(case when type = 2 then 1 else 0 end), /* relearn */
sum(case when type = 3 then 1 else 0 end) /* filter */
@ -544,15 +545,15 @@ group by day order by day"""
else:
tf = 3600.0 # hours
return self.col.db.all(
"""
f"""
select
(cast((id/1000.0 - :cut) / 86400.0 as int))/:chunk as day,
sum(case when type = 0 then 1 else 0 end), -- lrn count
sum(case when type = {REVLOG_LRN} then 1 else 0 end), -- lrn count
sum(case when type = 1 and lastIvl < 21 then 1 else 0 end), -- yng count
sum(case when type = 1 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 = 3 then 1 else 0 end), -- cram count
sum(case when type = 0 then time/1000.0 else 0 end)/:tf, -- lrn time
sum(case when type = {REVLOG_LRN} then time/1000.0 else 0 end)/:tf, -- lrn time
-- yng + mtr time
sum(case when type = 1 and lastIvl < 21 then time/1000.0 else 0 end)/:tf,
sum(case when type = 1 and lastIvl >= 21 then time/1000.0 else 0 end)/:tf,
@ -755,12 +756,12 @@ select count(), avg(ivl), max(ivl) from cards where did in %s and queue = 2"""
else:
ease4repl = "ease"
return self.col.db.all(
"""
f"""
select (case
when type in (0,2) then 0
when type in ({REVLOG_LRN},2) then 0
when lastIvl < 21 then 1
else 2 end) as thetype,
(case when type in (0,2) and ease = 4 then %s else ease end), count() from revlog %s
(case when type in ({REVLOG_LRN},2) and ease = 4 then %s else ease end), count() from revlog %s
group by thetype, ease
order by thetype, ease"""
% (ease4repl, lim)
@ -849,13 +850,13 @@ order by thetype, ease"""
if pd:
lim += " and id > %d" % ((self.col.sched.dayCutoff - (86400 * pd)) * 1000)
return self.col.db.all(
"""
f"""
select
23 - ((cast((:cut - id/1000) / 3600.0 as int)) %% 24) as hour,
sum(case when ease = 1 then 0 else 1 end) /
cast(count() as float) * 100,
count()
from revlog where type in (0,1,2) %s
from revlog where type in ({REVLOG_LRN},1,2) %s
group by hour having count() > 30 order by hour"""
% lim,
cut=self.col.sched.dayCutoff - (rolloverHour * 3600),