mirror of
https://github.com/ankitects/anki.git
synced 2025-11-13 16:17:13 -05:00
remove redundant new cards from graphs, rewrite queries
This commit is contained in:
parent
7b2abd7153
commit
7463ef570b
1 changed files with 15 additions and 18 deletions
|
|
@ -43,7 +43,6 @@ class DeckGraphs(object):
|
||||||
def calcStats (self):
|
def calcStats (self):
|
||||||
if not self.stats:
|
if not self.stats:
|
||||||
days = {}
|
days = {}
|
||||||
daysNew = {}
|
|
||||||
daysYoung = {}
|
daysYoung = {}
|
||||||
daysMature = {}
|
daysMature = {}
|
||||||
months = {}
|
months = {}
|
||||||
|
|
@ -53,17 +52,16 @@ class DeckGraphs(object):
|
||||||
now[3] = 23; now[4] = 59
|
now[3] = 23; now[4] = 59
|
||||||
self.endOfDay = time.mktime(now) + self.deck.utcOffset
|
self.endOfDay = time.mktime(now) + self.deck.utcOffset
|
||||||
t = time.time()
|
t = time.time()
|
||||||
new = self.deck.s.all("""
|
|
||||||
select interval, combinedDue
|
|
||||||
from cards where reps > 0 and priority != 0 and type = 2""")
|
|
||||||
young = self.deck.s.all("""
|
young = self.deck.s.all("""
|
||||||
select interval, combinedDue
|
select interval, combinedDue
|
||||||
from cards where reps > 0 and priority != 0 and (type = 0 or (type = 1 and interval <= 21))""")
|
from cards where priority in (1,2,3,4) and
|
||||||
|
type in (0, 1) and interval <= 21""")
|
||||||
mature = self.deck.s.all("""
|
mature = self.deck.s.all("""
|
||||||
select interval, combinedDue
|
select interval, combinedDue
|
||||||
from cards where reps > 0 and priority != 0 and type = 1 and interval > 21""")
|
from cards where type = 1 and priority in (1,2,3,4) and interval > 21""")
|
||||||
|
|
||||||
for (src, dest) in [(new, daysNew), (young, daysYoung), (mature, daysMature)]:
|
for (src, dest) in [(young, daysYoung),
|
||||||
|
(mature, daysMature)]:
|
||||||
for (interval, due) in src:
|
for (interval, due) in src:
|
||||||
day=int(round(interval))
|
day=int(round(interval))
|
||||||
days[day] = days.get(day, 0) + 1
|
days[day] = days.get(day, 0) + 1
|
||||||
|
|
@ -76,8 +74,7 @@ from cards where reps > 0 and priority != 0 and type = 1 and interval > 21""")
|
||||||
self.stats = {}
|
self.stats = {}
|
||||||
self.stats['next'] = next
|
self.stats['next'] = next
|
||||||
self.stats['days'] = days
|
self.stats['days'] = days
|
||||||
self.stats['daysByType'] = {'new': daysNew,
|
self.stats['daysByType'] = {'young': daysYoung,
|
||||||
'young': daysYoung,
|
|
||||||
'mature': daysMature}
|
'mature': daysMature}
|
||||||
self.stats['months'] = months
|
self.stats['months'] = months
|
||||||
self.stats['lowestInDay'] = lowestInDay
|
self.stats['lowestInDay'] = lowestInDay
|
||||||
|
|
@ -86,25 +83,25 @@ from cards where reps > 0 and priority != 0 and type = 1 and interval > 21""")
|
||||||
self.calcStats()
|
self.calcStats()
|
||||||
fig = Figure(figsize=(self.width, self.height), dpi=self.dpi)
|
fig = Figure(figsize=(self.width, self.height), dpi=self.dpi)
|
||||||
graph = fig.add_subplot(111)
|
graph = fig.add_subplot(111)
|
||||||
dayslists = [self.stats['next'], self.stats['daysByType']['young'], self.stats['daysByType']['new']]
|
dayslists = [self.stats['next'], self.stats['daysByType']['young']]
|
||||||
|
|
||||||
for dayslist in dayslists:
|
for dayslist in dayslists:
|
||||||
self.addMissing(dayslist, self.stats['lowestInDay'], days)
|
self.addMissing(dayslist, self.stats['lowestInDay'], days)
|
||||||
|
|
||||||
for i in range(days):
|
# what is this doing?
|
||||||
dayslists[1][i] += dayslists[2][i]
|
# for i in range(days):
|
||||||
|
# dayslists[0][i] += dayslists[1][i]
|
||||||
|
|
||||||
argl = []
|
argl = []
|
||||||
|
|
||||||
for dayslist in dayslists:
|
for dayslist in dayslists:
|
||||||
argl.extend(list(self.unzip(dayslist.items())))
|
argl.extend(list(self.unzip(dayslist.items())))
|
||||||
|
|
||||||
self.filledGraph(graph, days, ["#7777ff", "#77ffff", "#ff7777"], *argl)
|
self.filledGraph(graph, days, ["#7777ff", "#77ffff"], *argl)
|
||||||
|
|
||||||
cheat = fig.add_subplot(111)
|
cheat = fig.add_subplot(111)
|
||||||
cheat.bar(0, 0, color = "#ff7777", label = _("New cards"))
|
cheat.bar(0, 0, color = "#77ffff", label = _("Young cards"))
|
||||||
cheat.bar(1, 0, color = "#77ffff", label = _("Young cards"))
|
cheat.bar(1, 0, color = "#7777ff", label = _("Mature cards"))
|
||||||
cheat.bar(2, 0, color = "#7777ff", label = _("Mature cards"))
|
|
||||||
|
|
||||||
cheat.legend(loc = 'upper right')
|
cheat.legend(loc = 'upper right')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue