show # of reviews per hour

This commit is contained in:
Damien Elmes 2012-05-06 16:51:42 +09:00
parent 63872f51cd
commit 8a4d20de16

View file

@ -87,7 +87,7 @@ colLearn = "#00F"
colRelearn = "#c00" colRelearn = "#c00"
colCram = "#ff0" colCram = "#ff0"
colIvl = "#077" colIvl = "#077"
colHour = "#777" colHour = "#ccc"
colTime = "#770" colTime = "#770"
colUnseen = "#000" colUnseen = "#000"
colSusp = "#ff0" colSusp = "#ff0"
@ -488,6 +488,8 @@ order by thetype, ease""" % lim)
if not data: if not data:
return "" return ""
shifted = [] shifted = []
counts = []
mcount = 0
trend = [] trend = []
peak = 0 peak = 0
for d in data: for d in data:
@ -496,7 +498,11 @@ order by thetype, ease""" % lim)
if pct > peak: if pct > peak:
peak = pct peak = pct
shifted.append((hour, pct)) shifted.append((hour, pct))
counts.append((hour, d[2]))
if d[2] > mcount:
mcount = d[2]
shifted.sort() shifted.sort()
counts.sort()
for d in shifted: for d in shifted:
hour = d[0] hour = d[0]
pct = d[1] pct = d[1]
@ -508,17 +514,18 @@ order by thetype, ease""" % lim)
diff /= 3.0 diff /= 3.0
diff = round(diff, 1) diff = round(diff, 1)
trend.append((hour, prev+diff)) trend.append((hour, prev+diff))
txt = self._title(_("Hourly Retention"), txt = self._title(_("Hourly Breakdown"),
_("Review success rate for each hour of the day.")) _("Review success rate for each hour of the day."))
txt += self._graph(id="hour", data=[ txt += self._graph(id="hour", data=[
dict(data=shifted, color=colHour, label=_("% Correct")), dict(data=shifted, color=colCum, label=_("% Correct")),
dict(data=trend, color=colCum, label=_("Trend"), dict(data=counts, color=colHour, label=_("Answers"), yaxis=2,
bars={'show': False}, lines=dict(show=True), stack=False) bars=dict(barWidth=0.2), stack=False)
], conf=dict( ], conf=dict(
xaxis=dict(ticks=[[0, _("4AM")], [6, _("10AM")], xaxis=dict(ticks=[[0, _("4AM")], [6, _("10AM")],
[12, _("4PM")], [18, _("10PM")], [23, _("3AM")]]), [12, _("4PM")], [18, _("10PM")], [23, _("3AM")]]),
yaxis=dict(max=peak)), yaxes=[dict(max=peak), dict(position="right", max=mcount)]),
ylabel=_("%Correct")) ylabel=_("% Correct"), ylabel2=_("Reviews"))
txt += _("Hours with less than 30 reviews are not shown.")
return txt return txt
def _hourRet(self): def _hourRet(self):