PERIOD_MONTH

This commit is contained in:
Arthur Milchior 2020-02-03 01:44:17 -08:00
parent 600c70edcb
commit 3fa0a07e2e

View file

@ -13,6 +13,8 @@ from anki.utils import fmtTimeSpan, ids2str
# Card stats # Card stats
########################################################################## ##########################################################################
PERIOD_MONTH = 0
class CardStats: class CardStats:
def __init__(self, col, card) -> None: def __init__(self, col, card) -> None:
@ -103,14 +105,14 @@ class CollectionStats:
def __init__(self, col) -> None: def __init__(self, col) -> None:
self.col = col self.col = col
self._stats = None self._stats = None
self.type = 0 self.type = PERIOD_MONTH
self.width = 600 self.width = 600
self.height = 200 self.height = 200
self.wholeCollection = False self.wholeCollection = False
# assumes jquery & plot are available in document # assumes jquery & plot are available in document
def report(self, type=0) -> str: def report(self, type=PERIOD_MONTH) -> str:
# 0=days, 1=weeks, 2=months # 0=month, 1=weeks, 2=months
self.type = type self.type = type
from .statsbg import bg from .statsbg import bg
@ -216,7 +218,7 @@ from revlog where id > ? """
def get_start_end_chunk(self, by="review") -> Tuple[int, Optional[int], int]: def get_start_end_chunk(self, by="review") -> Tuple[int, Optional[int], int]:
start = 0 start = 0
if self.type == 0: if self.type == PERIOD_MONTH:
end, chunk = 31, 1 end, chunk = 31, 1
elif self.type == 1: elif self.type == 1:
end, chunk = 52, 7 end, chunk = 52, 7
@ -397,7 +399,7 @@ group by day order by day"""
(10, colCram, _("Cram")), (10, colCram, _("Cram")),
), ),
) )
if self.type == 0: if self.type == PERIOD_MONTH:
t = _("Minutes") t = _("Minutes")
convHours = False convHours = False
else: else:
@ -510,7 +512,7 @@ group by day order by day"""
lim = "where " + " and ".join(lims) lim = "where " + " and ".join(lims)
else: else:
lim = "" lim = ""
if self.type == 0: if self.type == PERIOD_MONTH:
tf = 60.0 # minutes tf = 60.0 # minutes
else: else:
tf = 3600.0 # hours tf = 3600.0 # hours
@ -540,7 +542,7 @@ group by day order by day"""
lim = "where " + " and ".join(lims) lim = "where " + " and ".join(lims)
else: else:
lim = "" lim = ""
if self.type == 0: if self.type == PERIOD_MONTH:
tf = 60.0 # minutes tf = 60.0 # minutes
else: else:
tf = 3600.0 # hours tf = 3600.0 # hours
@ -603,7 +605,7 @@ group by day order by day)"""
for (grp, cnt) in ivls: for (grp, cnt) in ivls:
tot += cnt tot += cnt
totd.append((grp, tot / float(all) * 100)) totd.append((grp, tot / float(all) * 100))
if self.type == 0: if self.type == PERIOD_MONTH:
ivlmax = 31 ivlmax = 31
elif self.type == 1: elif self.type == 1:
ivlmax = 52 ivlmax = 52
@ -711,7 +713,7 @@ select count(), avg(ivl), max(ivl) from cards where did in %s and queue = 2"""
return txt return txt
def _easeInfo(self, eases) -> str: def _easeInfo(self, eases) -> str:
types = {0: [0, 0], 1: [0, 0], 2: [0, 0]} types = {PERIOD_MONTH: [0, 0], 1: [0, 0], 2: [0, 0]}
for (type, ease, cnt) in eases: for (type, ease, cnt) in eases:
if ease == 1: if ease == 1:
types[type][0] += cnt types[type][0] += cnt