Prise en compte des valeurs vides des durées des revues. closes #6
This commit is contained in:
parent
67be80a598
commit
27df2d4d65
@ -11,7 +11,7 @@ class ReviewData:
|
||||
|
||||
|
||||
class Board:
|
||||
def __init__(self, datas):
|
||||
def __init__(self, datas={}):
|
||||
self.datas = {}
|
||||
self.init(datas)
|
||||
|
||||
@ -34,32 +34,34 @@ class Board:
|
||||
|
||||
@property
|
||||
def min(self):
|
||||
if self.datas == []:
|
||||
if self.datas == {}:
|
||||
return 0
|
||||
return min(self.datas.values())
|
||||
return min(self.datas.keys())
|
||||
|
||||
@property
|
||||
def max(self):
|
||||
if self.datas == []:
|
||||
if self.datas == {}:
|
||||
return 0
|
||||
return max(self.datas.values())
|
||||
return max(self.datas.keys())
|
||||
|
||||
@property
|
||||
def avg(self):
|
||||
if self.datas == []:
|
||||
if self.datas == {}:
|
||||
return 0
|
||||
return self.sum / len(self.datas)
|
||||
return self.sum / sum(self.datas.values())
|
||||
|
||||
@property
|
||||
def sum(self):
|
||||
if self.datas == []:
|
||||
return 0
|
||||
return sum(self.datas.values())
|
||||
result = 0
|
||||
for data in self.datas:
|
||||
result += self.datas[data] * data
|
||||
return result
|
||||
|
||||
|
||||
class UserBoard(Board):
|
||||
def init(self, datas):
|
||||
for data in datas:
|
||||
if data.user_count is not None:
|
||||
if data.user_count not in self.datas:
|
||||
self.datas[data.user_count] = 0
|
||||
self.datas[data.user_count] += 1
|
||||
@ -68,6 +70,7 @@ class UserBoard(Board):
|
||||
class DurationBoard(Board):
|
||||
def init(self, datas):
|
||||
for data in datas:
|
||||
if data.duration is not None:
|
||||
if data.duration not in self.datas:
|
||||
self.datas[data.duration] = 0
|
||||
self.datas[data.duration] += 1
|
||||
@ -159,7 +162,7 @@ class ReviewStats:
|
||||
ReviewData(
|
||||
datetime.strptime(datas[0], "%Y%m%d-%Hh%M"),
|
||||
int(datas[1]),
|
||||
int(datas[2]),
|
||||
int(datas[2]) if datas[2]!="" else None,
|
||||
)
|
||||
)
|
||||
except FileNotFoundError:
|
||||
|
Loading…
Reference in New Issue
Block a user