Prise en compte des valeurs vides des durées des revues. closes #6

This commit is contained in:
Mindiell 2024-06-27 18:53:05 +02:00
parent 67be80a598
commit 27df2d4d65

View File

@ -11,7 +11,7 @@ class ReviewData:
class Board: class Board:
def __init__(self, datas): def __init__(self, datas={}):
self.datas = {} self.datas = {}
self.init(datas) self.init(datas)
@ -34,43 +34,46 @@ class Board:
@property @property
def min(self): def min(self):
if self.datas == []: if self.datas == {}:
return 0 return 0
return min(self.datas.values()) return min(self.datas.keys())
@property @property
def max(self): def max(self):
if self.datas == []: if self.datas == {}:
return 0 return 0
return max(self.datas.values()) return max(self.datas.keys())
@property @property
def avg(self): def avg(self):
if self.datas == []: if self.datas == {}:
return 0 return 0
return self.sum / len(self.datas) return self.sum / sum(self.datas.values())
@property @property
def sum(self): def sum(self):
if self.datas == []: result = 0
return 0 for data in self.datas:
return sum(self.datas.values()) result += self.datas[data] * data
return result
class UserBoard(Board): class UserBoard(Board):
def init(self, datas): def init(self, datas):
for data in datas: for data in datas:
if data.user_count not in self.datas: if data.user_count is not None:
self.datas[data.user_count] = 0 if data.user_count not in self.datas:
self.datas[data.user_count] += 1 self.datas[data.user_count] = 0
self.datas[data.user_count] += 1
class DurationBoard(Board): class DurationBoard(Board):
def init(self, datas): def init(self, datas):
for data in datas: for data in datas:
if data.duration not in self.datas: if data.duration is not None:
self.datas[data.duration] = 0 if data.duration not in self.datas:
self.datas[data.duration] += 1 self.datas[data.duration] = 0
self.datas[data.duration] += 1
class ReviewStats: class ReviewStats:
@ -159,7 +162,7 @@ class ReviewStats:
ReviewData( ReviewData(
datetime.strptime(datas[0], "%Y%m%d-%Hh%M"), datetime.strptime(datas[0], "%Y%m%d-%Hh%M"),
int(datas[1]), int(datas[1]),
int(datas[2]), int(datas[2]) if datas[2]!="" else None,
) )
) )
except FileNotFoundError: except FileNotFoundError: