mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 00:12:25 -04:00
remove stats from graphs; use revlog
This commit is contained in:
parent
b837b92ef2
commit
9ce60d5e3a
2 changed files with 26 additions and 28 deletions
|
@ -98,18 +98,7 @@ from cards c where relativeDelay = 1 and type >= 0 and interval > 21"""
|
||||||
self.stats['months'] = months
|
self.stats['months'] = months
|
||||||
self.stats['lowestInDay'] = lowestInDay
|
self.stats['lowestInDay'] = lowestInDay
|
||||||
|
|
||||||
dayReps = self.deck.s.all("""
|
dayReps = self.getDayReps()
|
||||||
select day,
|
|
||||||
matureEase0+matureEase1+matureEase2+matureEase3+matureEase4 as matureReps,
|
|
||||||
reps-(newEase0+newEase1+newEase2+newEase3+newEase4) as combinedYoungReps,
|
|
||||||
reps as combinedNewReps
|
|
||||||
from stats
|
|
||||||
where type = 1""")
|
|
||||||
|
|
||||||
dayTimes = self.deck.s.all("""
|
|
||||||
select day, reviewTime as reviewTime
|
|
||||||
from stats
|
|
||||||
where type = 1""")
|
|
||||||
|
|
||||||
todaydt = self.deck._dailyStats.day
|
todaydt = self.deck._dailyStats.day
|
||||||
for dest, source in [("dayRepsNew", "combinedNewReps"),
|
for dest, source in [("dayRepsNew", "combinedNewReps"),
|
||||||
|
@ -121,7 +110,18 @@ where type = 1""")
|
||||||
|
|
||||||
self.stats['dayTimes'] = dict(
|
self.stats['dayTimes'] = dict(
|
||||||
map(lambda dr: (-(todaydt -datetime.date(
|
map(lambda dr: (-(todaydt -datetime.date(
|
||||||
*(int(x)for x in dr["day"].split("-")))).days, dr["reviewTime"]/60.0), dayTimes))
|
*(int(x)for x in dr["day"].split("-")))).days, dr["reviewTime"]/60.0), dayReps))
|
||||||
|
|
||||||
|
def getDayReps(self):
|
||||||
|
return self.deck.s.all("""
|
||||||
|
select
|
||||||
|
count() as combinedNewReps,
|
||||||
|
date(time-:off, "unixepoch") as day,
|
||||||
|
sum(case when lastInterval > 21 then 1 else 0 end) as matureReps,
|
||||||
|
count() - sum(case when reps = 1 then 1 else 0 end) as combinedYoungReps,
|
||||||
|
sum(thinkingTime) as reviewTime from reviewHistory
|
||||||
|
group by day order by day
|
||||||
|
""", off=self.deck.utcOffset)
|
||||||
|
|
||||||
def nextDue(self, days=30):
|
def nextDue(self, days=30):
|
||||||
self.calcStats()
|
self.calcStats()
|
||||||
|
@ -361,30 +361,28 @@ where type = 1""")
|
||||||
offset = 0
|
offset = 0
|
||||||
arrsize = 16
|
arrsize = 16
|
||||||
arr = [0] * arrsize
|
arr = [0] * arrsize
|
||||||
n = 0
|
|
||||||
colours = [easesNewC, easesYoungC, easesMatureC]
|
colours = [easesNewC, easesYoungC, easesMatureC]
|
||||||
bars = []
|
bars = []
|
||||||
gs = anki.stats.globalStats(self.deck)
|
eases = self.deck.s.all("""
|
||||||
for type in types:
|
select (case when reps = 1 then 0 when lastInterval <= 21 then 1 else 2 end)
|
||||||
total = (getattr(gs, type + "Ease0") +
|
as type, ease, count() from reviewHistory group by type, ease""")
|
||||||
getattr(gs, type + "Ease1") +
|
d = {}
|
||||||
getattr(gs, type + "Ease2") +
|
for (type, ease, count) in eases:
|
||||||
getattr(gs, type + "Ease3") +
|
type = types[type]
|
||||||
getattr(gs, type + "Ease4"))
|
if type not in d:
|
||||||
setattr(gs, type + "Ease1", getattr(gs, type + "Ease0") +
|
d[type] = {}
|
||||||
getattr(gs, type + "Ease1"))
|
d[type][ease] = count
|
||||||
setattr(gs, type + "Ease0", -1)
|
for n, type in enumerate(types):
|
||||||
|
total = float(sum(d[type].values()))
|
||||||
for e in range(1, enum):
|
for e in range(1, enum):
|
||||||
try:
|
try:
|
||||||
arr[e+offset] = (getattr(gs, type + "Ease%d" % e)
|
arr[e+offset] = (d[type][e] / total) * 100 + 1
|
||||||
/ float(total)) * 100 + 1
|
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
arr[e+offset] = 0
|
arr[e+offset] = 0
|
||||||
bars.append(graph.bar(range(arrsize), arr, width=1.0,
|
bars.append(graph.bar(range(arrsize), arr, width=1.0,
|
||||||
color=colours[n], align='center'))
|
color=colours[n], align='center'))
|
||||||
arr = [0] * arrsize
|
arr = [0] * arrsize
|
||||||
offset += 5
|
offset += 5
|
||||||
n += 1
|
|
||||||
x = ([""] + [str(n) for n in range(1, enum)]) * 3
|
x = ([""] + [str(n) for n in range(1, enum)]) * 3
|
||||||
graph.legend([p[0] for p in bars], ("New",
|
graph.legend([p[0] for p in bars], ("New",
|
||||||
"Young",
|
"Young",
|
||||||
|
|
|
@ -488,7 +488,7 @@ class DeckStats(object):
|
||||||
y = today + 86400*finish
|
y = today + 86400*finish
|
||||||
return self.deck.s.scalar("""
|
return self.deck.s.scalar("""
|
||||||
select count(distinct(cast((time-:off)/86400 as integer))) from reviewHistory
|
select count(distinct(cast((time-:off)/86400 as integer))) from reviewHistory
|
||||||
where time >= :x and time <= :y""",x=x,y=y, off=-self.deck.utcOffset)
|
where time >= :x and time <= :y""",x=x,y=y, off=self.deck.utcOffset)
|
||||||
|
|
||||||
def getRepsDone(self, start, finish):
|
def getRepsDone(self, start, finish):
|
||||||
now = datetime.datetime.today()
|
now = datetime.datetime.today()
|
||||||
|
|
Loading…
Reference in a new issue