mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
very basic eta
This commit is contained in:
parent
19fd581839
commit
0bbdd722c2
2 changed files with 31 additions and 0 deletions
|
@ -95,6 +95,25 @@ order by due""" % self._groupLimit(),
|
||||||
self.deck.db.execute(
|
self.deck.db.execute(
|
||||||
"update cards set queue = type where queue between -3 and -2")
|
"update cards set queue = type where queue between -3 and -2")
|
||||||
|
|
||||||
|
def etaStr(self):
|
||||||
|
eta = self.eta()
|
||||||
|
if not eta:
|
||||||
|
return ""
|
||||||
|
return fmtTimeSpan(eta)
|
||||||
|
|
||||||
|
def eta(self):
|
||||||
|
"A very rough estimate of time to review."
|
||||||
|
(cnt, sum) = self.deck.db.first("""
|
||||||
|
select count(), sum(taken) from (select * from revlog
|
||||||
|
order by time desc limit 100)""")
|
||||||
|
if not cnt:
|
||||||
|
return 0
|
||||||
|
avg = sum / float(cnt)
|
||||||
|
c = self.counts()
|
||||||
|
# Here we just assume new/lrn will require 3x the number of reviews. A
|
||||||
|
# more complex solution can be added in the future.
|
||||||
|
return (avg*c[0]*3 + avg*c[1]*3 + avg*c[2]) / 1000.0
|
||||||
|
|
||||||
# Counts
|
# Counts
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
|
@ -794,3 +794,15 @@ def test_resched():
|
||||||
c.load()
|
c.load()
|
||||||
assert c.due == d.sched.today+1
|
assert c.due == d.sched.today+1
|
||||||
assert c.ivl == +1
|
assert c.ivl == +1
|
||||||
|
|
||||||
|
def test_eta():
|
||||||
|
d = getEmptyDeck()
|
||||||
|
f = d.newFact()
|
||||||
|
f['Front'] = u"one"
|
||||||
|
d.addFact(f)
|
||||||
|
d.reset()
|
||||||
|
c = d.sched.getCard()
|
||||||
|
time.sleep(0.1)
|
||||||
|
d.sched.answerCard(c, 1)
|
||||||
|
time.sleep(0.1)
|
||||||
|
d.sched.answerCard(c, 1)
|
||||||
|
|
Loading…
Reference in a new issue