mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
add intervals, boxing in weeks for now
This commit is contained in:
parent
89fa08c548
commit
7d5d72adf8
2 changed files with 26 additions and 20 deletions
|
@ -72,19 +72,6 @@ class Graphs(object):
|
||||||
graph.set_ylabel("Minutes")
|
graph.set_ylabel("Minutes")
|
||||||
return fig
|
return fig
|
||||||
|
|
||||||
def ivlPeriod(self, days=30):
|
|
||||||
self._calcStats()
|
|
||||||
fig = Figure(figsize=(self.width, self.height), dpi=self.dpi)
|
|
||||||
ints = self.stats['days']
|
|
||||||
self._addMissing(ints, 0, days)
|
|
||||||
ivls = self._unzip(ints.items(), limit=days)
|
|
||||||
graph = fig.add_subplot(111)
|
|
||||||
self._varGraph(graph, days, intervC, *ivls)
|
|
||||||
graph.set_xlim(xmin=0, xmax=days+1)
|
|
||||||
graph.set_xlabel("Card Interval")
|
|
||||||
graph.set_ylabel("Number of Cards")
|
|
||||||
return fig
|
|
||||||
|
|
||||||
def addedRecently(self, numdays=30, attr='crt'):
|
def addedRecently(self, numdays=30, attr='crt'):
|
||||||
self._calcStats()
|
self._calcStats()
|
||||||
days = {}
|
days = {}
|
||||||
|
@ -167,6 +154,7 @@ as type, ease, count() from revlog group by type, ease""")
|
||||||
return
|
return
|
||||||
self._stats = {}
|
self._stats = {}
|
||||||
self._stats['due'] = self._dueCards()
|
self._stats['due'] = self._dueCards()
|
||||||
|
self._stats['ivls'] = self._ivls()
|
||||||
return
|
return
|
||||||
|
|
||||||
days = {}
|
days = {}
|
||||||
|
@ -219,17 +207,13 @@ from cards where queue = 1 and ivl > 21"""
|
||||||
*(int(x)for x in dr[1].split("-")))).days, dr[4]/60.0), dayReps))
|
*(int(x)for x in dr[1].split("-")))).days, dr[4]/60.0), dayReps))
|
||||||
|
|
||||||
def _dueCards(self, days=7):
|
def _dueCards(self, days=7):
|
||||||
if self.selective:
|
|
||||||
extra = self.deck.sched._groupLimit("rev")
|
|
||||||
else:
|
|
||||||
extra = ""
|
|
||||||
return self.deck.db.all("""
|
return self.deck.db.all("""
|
||||||
select due-:today,
|
select due-:today,
|
||||||
count(), -- all
|
count(), -- all
|
||||||
sum(case when ivl >= 21 then 1 else 0 end) -- mature
|
sum(case when ivl >= 21 then 1 else 0 end) -- mature
|
||||||
from cards
|
from cards
|
||||||
where queue = 2 and due < (:today+:days) %s
|
where queue = 2 and due < (:today+:days) %s
|
||||||
group by due order by due""" % extra,
|
group by due order by due""" % self._limit(),
|
||||||
today=self.deck.sched.today, days=days)
|
today=self.deck.sched.today, days=days)
|
||||||
|
|
||||||
def _graph(self, id, data, conf={}, width=600, height=200):
|
def _graph(self, id, data, conf={}, width=600, height=200):
|
||||||
|
@ -274,12 +258,34 @@ $(function () {
|
||||||
for day in d:
|
for day in d:
|
||||||
tot += day[1]+day[2]
|
tot += day[1]+day[2]
|
||||||
days.append((day[0], tot))
|
days.append((day[0], tot))
|
||||||
txt = self._graph(id="due", data=[
|
txt = self._graph(id="cum", data=[
|
||||||
dict(data=days, lines=dict(show=True, fill=True),
|
dict(data=days, lines=dict(show=True, fill=True),
|
||||||
color=dueCumulC, label=_("Cards")),
|
color=dueCumulC, label=_("Cards")),
|
||||||
])
|
])
|
||||||
self.save(txt)
|
self.save(txt)
|
||||||
|
|
||||||
|
def _limit(self):
|
||||||
|
if self.selective:
|
||||||
|
return self.deck.sched._groupLimit("rev")
|
||||||
|
else:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def _ivls(self):
|
||||||
|
return self.deck.db.all("""
|
||||||
|
select ivl / 7, count() from cards
|
||||||
|
where queue = 2 %s
|
||||||
|
group by ivl / 7
|
||||||
|
order by ivl / 7""" % self._limit())
|
||||||
|
|
||||||
|
def ivlGraph(self):
|
||||||
|
self._calcStats()
|
||||||
|
ivls = self._stats['ivls']
|
||||||
|
txt = self._graph(id="ivl", data=[
|
||||||
|
dict(data=ivls, bars=dict(show=True, barWidth=0.8),
|
||||||
|
color=intervC)
|
||||||
|
])
|
||||||
|
self.save(txt)
|
||||||
|
|
||||||
def _getDayReps(self):
|
def _getDayReps(self):
|
||||||
return self.deck.db.all("""
|
return self.deck.db.all("""
|
||||||
select
|
select
|
||||||
|
|
|
@ -27,7 +27,7 @@ def test_graphs():
|
||||||
d = Deck(os.path.expanduser("~/test.anki"))
|
d = Deck(os.path.expanduser("~/test.anki"))
|
||||||
g = d.graphs()
|
g = d.graphs()
|
||||||
g._calcStats()
|
g._calcStats()
|
||||||
g.cumDueGraph()
|
g.ivlGraph()
|
||||||
return
|
return
|
||||||
g.nextDue()
|
g.nextDue()
|
||||||
g.workDone()
|
g.workDone()
|
||||||
|
|
Loading…
Reference in a new issue