mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 09:16:38 -04:00
simplify graph calls
This commit is contained in:
parent
3c5c21f6a6
commit
91903a79be
1 changed files with 34 additions and 23 deletions
|
@ -27,20 +27,9 @@ class Graphs(object):
|
||||||
|
|
||||||
def report(self, type=0):
|
def report(self, type=0):
|
||||||
# 0=days, 1=weeks, 2=months
|
# 0=days, 1=weeks, 2=months
|
||||||
fc = _("Forecast")
|
|
||||||
rc = _("Review Count")
|
|
||||||
rt = _("Review Time")
|
|
||||||
txt = ""
|
|
||||||
# period-dependent graphs
|
# period-dependent graphs
|
||||||
if type == 0:
|
txt = self.dueGraph(type)
|
||||||
txt += self.dueGraph(0, 30, fc)
|
txt += self.repsGraph(type)
|
||||||
txt += self.repsGraph(30, rc, rt)
|
|
||||||
elif type == 1:
|
|
||||||
txt += self.dueGraph(0, 52, fc, chunk=7)
|
|
||||||
txt += self.repsGraph(52, rc, rt, chunk=7)
|
|
||||||
else:
|
|
||||||
txt += self.dueGraph(0, None, fc, chunk=30)
|
|
||||||
txt += self.repsGraph(None, rc, rt, chunk=30)
|
|
||||||
# other graphs
|
# other graphs
|
||||||
txt += self.ivlGraph()
|
txt += self.ivlGraph()
|
||||||
txt += self.easeGraph()
|
txt += self.easeGraph()
|
||||||
|
@ -49,8 +38,17 @@ class Graphs(object):
|
||||||
# Due and cumulative due
|
# Due and cumulative due
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def dueGraph(self, start, end, title, chunk=1):
|
def dueGraph(self, type):
|
||||||
d = self._due(start, end, chunk)
|
if type == 0:
|
||||||
|
start = 0; end = 30; chunk = 1
|
||||||
|
elif type == 1:
|
||||||
|
start = 0; end = 52; chunk = 7
|
||||||
|
elif type == 2:
|
||||||
|
start = 0; end = None; chunk = 30
|
||||||
|
return self._dueGraph(self._due(start, end, chunk), _("Forecast"))
|
||||||
|
|
||||||
|
def _dueGraph(self, data, title):
|
||||||
|
d = data
|
||||||
yng = []
|
yng = []
|
||||||
mtr = []
|
mtr = []
|
||||||
tot = 0
|
tot = 0
|
||||||
|
@ -90,8 +88,20 @@ group by day order by day""" % (self._limit(), lim),
|
||||||
# Reps and time spent
|
# Reps and time spent
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def repsGraph(self, days, reptitle, timetitle, chunk=1):
|
def repsGraph(self, type):
|
||||||
d = self._done(days, chunk)
|
if type == 0:
|
||||||
|
days = 30; chunk = 1
|
||||||
|
elif type == 1:
|
||||||
|
days = 52; chunk = 7
|
||||||
|
else:
|
||||||
|
days = None; chunk = 30
|
||||||
|
return self._repsGraph(self._done(days, chunk),
|
||||||
|
days,
|
||||||
|
_("Review Count"),
|
||||||
|
_("Review Time"))
|
||||||
|
|
||||||
|
def _repsGraph(self, data, days, reptitle, timetitle):
|
||||||
|
d = data
|
||||||
conf = dict(
|
conf = dict(
|
||||||
xaxis=dict(tickDecimals=0),
|
xaxis=dict(tickDecimals=0),
|
||||||
yaxes=[dict(), dict(position="right")])
|
yaxes=[dict(), dict(position="right")])
|
||||||
|
@ -169,6 +179,13 @@ group by day order by day""" % lim,
|
||||||
# Intervals
|
# Intervals
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
def ivlGraph(self):
|
||||||
|
ivls = self._ivls()
|
||||||
|
txt = self._graph(id="ivl", title=_("Intervals"), data=[
|
||||||
|
dict(data=ivls, color=colIvl)
|
||||||
|
])
|
||||||
|
return txt
|
||||||
|
|
||||||
def _ivls(self):
|
def _ivls(self):
|
||||||
return self.deck.db.all("""
|
return self.deck.db.all("""
|
||||||
select ivl / 7 as grp, count() from cards
|
select ivl / 7 as grp, count() from cards
|
||||||
|
@ -176,12 +193,6 @@ where queue = 2 %s
|
||||||
group by grp
|
group by grp
|
||||||
order by grp""" % self._limit())
|
order by grp""" % self._limit())
|
||||||
|
|
||||||
def ivlGraph(self):
|
|
||||||
ivls = self._ivls()
|
|
||||||
txt = self._graph(id="ivl", title=_("Intervals"), data=[
|
|
||||||
dict(data=ivls, color=colIvl)
|
|
||||||
])
|
|
||||||
return txt
|
|
||||||
|
|
||||||
# Eases
|
# Eases
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
Loading…
Reference in a new issue