v2: limit learn delay fuzz to 5 minutes and sub-day

This commit is contained in:
Damien Elmes 2018-07-28 13:49:04 +10:00
parent a728595c1d
commit 65f6ddf8d9
2 changed files with 8 additions and 5 deletions

View file

@ -585,12 +585,13 @@ did = ? and queue = 3 and due <= ? limit ?""",
if delay is None:
delay = self._delayForGrade(conf, card.left)
if card.due < time.time():
# not collapsed; add some randomness
delay *= random.uniform(1, 1.25)
card.due = int(time.time() + delay)
# due today?
if card.due < self.dayCutoff:
# add some randomness, up to 5 minutes or 25%
maxExtra = min(300, int(delay*0.25))
fuzz = random.randrange(0, maxExtra)
card.due = min(self.dayCutoff-1, card.due + fuzz)
card.queue = 1
if card.due < (intTime() + self.col.conf['collapseTime']):
self.lrnCount += 1

View file

@ -136,7 +136,8 @@ def test_learn():
# pass it once
d.sched.answerCard(c, 3)
# it should by due in 3 minutes
assert round(c.due - time.time()) in (179, 180)
dueIn = c.due - time.time()
assert 179 <= dueIn <= 180*1.25
assert c.left%1000 == 2
assert c.left//1000 == 2
# check log is accurate
@ -147,7 +148,8 @@ def test_learn():
# pass again
d.sched.answerCard(c, 3)
# it should by due in 10 minutes
assert round(c.due - time.time()) in (599, 600)
dueIn = c.due - time.time()
assert 599 <= dueIn <= 600*1.25
assert c.left%1000 == 1
assert c.left//1000 == 1
# the next pass should graduate the card