mirror of
https://github.com/ankitects/anki.git
synced 2025-11-09 14:17:13 -05:00
Refactor chunk calculation
This commit is contained in:
parent
858442a4c9
commit
66aef160b3
1 changed files with 13 additions and 30 deletions
|
|
@ -198,13 +198,17 @@ from revlog where id > ? """+lim, (self.col.sched.dayCutoff-86400)*1000)
|
||||||
# Due and cumulative due
|
# Due and cumulative due
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def dueGraph(self):
|
def get_start_end_chunk(self):
|
||||||
if self.type == 0:
|
if self.type == 0:
|
||||||
start, end, chunk = 0, 31, 1
|
start, end, chunk = 0, 31, 1
|
||||||
elif self.type == 1:
|
elif self.type == 1:
|
||||||
start, end, chunk = 0, 52, 7
|
start, end, chunk = 0, 52, 7
|
||||||
elif self.type == 2:
|
elif self.type == 2:
|
||||||
start, end, chunk = 0, None, 30
|
start, end, chunk = 0, None, 30
|
||||||
|
return start, end, chunk
|
||||||
|
|
||||||
|
def dueGraph(self):
|
||||||
|
start, end, chunk = self.get_start_end_chunk()
|
||||||
d = self._due(start, end, chunk)
|
d = self._due(start, end, chunk)
|
||||||
yng = []
|
yng = []
|
||||||
mtr = []
|
mtr = []
|
||||||
|
|
@ -269,12 +273,7 @@ group by day order by day""" % (self._limit(), lim),
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def introductionGraph(self):
|
def introductionGraph(self):
|
||||||
if self.type == 0:
|
start, days, chunk = self.get_start_end_chunk()
|
||||||
days = 30; chunk = 1
|
|
||||||
elif self.type == 1:
|
|
||||||
days = 52; chunk = 7
|
|
||||||
else:
|
|
||||||
days = None; chunk = 30
|
|
||||||
return self._introductionGraph(self._added(days, chunk),
|
return self._introductionGraph(self._added(days, chunk),
|
||||||
days, _("Added"))
|
days, _("Added"))
|
||||||
|
|
||||||
|
|
@ -309,12 +308,7 @@ group by day order by day""" % (self._limit(), lim),
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
def repsGraphs(self):
|
def repsGraphs(self):
|
||||||
if self.type == 0:
|
start, days, chunk = self.get_start_end_chunk()
|
||||||
days = 30; chunk = 1
|
|
||||||
elif self.type == 1:
|
|
||||||
days = 52; chunk = 7
|
|
||||||
else:
|
|
||||||
days = None; chunk = 30
|
|
||||||
return self._repsGraphs(self._done(days, chunk),
|
return self._repsGraphs(self._done(days, chunk),
|
||||||
days,
|
days,
|
||||||
_("Review Count"),
|
_("Review Count"),
|
||||||
|
|
@ -548,12 +542,8 @@ group by day order by day)""" % lim,
|
||||||
return txt + self._lineTbl(i)
|
return txt + self._lineTbl(i)
|
||||||
|
|
||||||
def _ivls(self):
|
def _ivls(self):
|
||||||
if self.type == 0:
|
start, end, chunk = self.get_start_end_chunk()
|
||||||
chunk = 1; lim = " and grp <= 30"
|
lim = "and grp <= %d" % end if end else ""
|
||||||
elif self.type == 1:
|
|
||||||
chunk = 7; lim = " and grp <= 52"
|
|
||||||
else:
|
|
||||||
chunk = 30; lim = ""
|
|
||||||
data = [self.col.db.all("""
|
data = [self.col.db.all("""
|
||||||
select ivl / :chunk as grp, count() from cards
|
select ivl / :chunk as grp, count() from cards
|
||||||
where did in %s and queue = 2 %s
|
where did in %s and queue = 2 %s
|
||||||
|
|
@ -625,12 +615,7 @@ select count(), avg(ivl), max(ivl) from cards where did in %s and queue = 2""" %
|
||||||
lim = self._revlogLimit()
|
lim = self._revlogLimit()
|
||||||
if lim:
|
if lim:
|
||||||
lims.append(lim)
|
lims.append(lim)
|
||||||
if self.type == 0:
|
days = self._periodDays()
|
||||||
days = 30
|
|
||||||
elif self.type == 1:
|
|
||||||
days = 365
|
|
||||||
else:
|
|
||||||
days = None
|
|
||||||
if days is not None:
|
if days is not None:
|
||||||
lims.append("id > %d" % (
|
lims.append("id > %d" % (
|
||||||
(self.col.sched.dayCutoff-(days*86400))*1000))
|
(self.col.sched.dayCutoff-(days*86400))*1000))
|
||||||
|
|
@ -937,12 +922,10 @@ $(function () {
|
||||||
return period
|
return period
|
||||||
|
|
||||||
def _periodDays(self):
|
def _periodDays(self):
|
||||||
if self.type == 0:
|
start, end, chunk = self.get_start_end_chunk()
|
||||||
return 30
|
if end is None:
|
||||||
elif self.type == 1:
|
|
||||||
return 365
|
|
||||||
else:
|
|
||||||
return None
|
return None
|
||||||
|
return end * chunk
|
||||||
|
|
||||||
def _avgDay(self, tot, num, unit):
|
def _avgDay(self, tot, num, unit):
|
||||||
vals = []
|
vals = []
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue