add review time graph

This commit is contained in:
Damien Elmes 2009-01-05 14:57:28 +09:00
parent 8bb063c226
commit 86e3c19ad6

View file

@ -21,6 +21,7 @@ dueCumulC = "#ff8080"
reviewNewC = "#80b3ff"
reviewYoungC = "#5555ff"
reviewMatureC = "#0f5aff"
reviewTimeC = "#0fcaff"
easesNewC = "#80b3ff"
easesYoungC = "#5555ff"
@ -104,14 +105,25 @@ select day,
reps-(newEase0+newEase1+newEase2+newEase3+newEase4) as combinedYoungReps,
reps as combinedNewReps
from stats
where type = 1""")
dayTimes = self.deck.s.all("""
select day, reviewTime
from stats
where type = 1""")
todaydt = datetime.datetime(*list(time.localtime(time.time())[:3]))
for dest, source in [("dayRepsNew", "combinedNewReps"), ("dayRepsYoung", "combinedYoungReps"), ("dayRepsMature", "matureReps")]:
for dest, source in [("dayRepsNew", "combinedNewReps"),
("dayRepsYoung", "combinedYoungReps"),
("dayRepsMature", "matureReps")]:
self.stats[dest] = dict(
map(lambda dr: (-(todaydt -datetime.datetime(
*(int(x)for x in dr["day"].split("-")))).days, dr[source]), dayReps))
self.stats['dayTimes'] = dict(
map(lambda dr: (-(todaydt -datetime.datetime(
*(int(x)for x in dr["day"].split("-")))).days, dr["reviewTime"]/60.0), dayTimes))
def nextDue(self, days=30):
self.calcStats()
fig = Figure(figsize=(self.width, self.height), dpi=self.dpi)
@ -168,6 +180,18 @@ where type = 1""")
return fig
def timeSpent(self, days=30):
self.calcStats()
fig = Figure(figsize=(self.width, self.height), dpi=self.dpi)
times = self.stats['dayTimes']
self.addMissing(times, -days, 0)
times = self.unzip(times.items())
graph = fig.add_subplot(111)
self.filledGraph(graph, days, reviewTimeC, *times)
graph.set_xlim(xmin=-days, xmax=0)
graph.set_ylim(ymax=max(a for a in times[1]) + 10)
return fig
def cumulativeDue(self, days=30):
self.calcStats()
fig = Figure(figsize=(self.width, self.height), dpi=self.dpi)