alerts stats on alerts page
This commit is contained in:
@@ -95,9 +95,9 @@ def alert_get_stats(alert,nperiod=0):
|
||||
columns += condition.metric
|
||||
|
||||
workouts = Workout.objects.filter(date__gte=startdate,date__lte=enddate,user=alert.rower,
|
||||
workouttype=alert.workouttype)
|
||||
workouttype=alert.workouttype,duplicate=False)
|
||||
ids = [w.id for w in workouts]
|
||||
|
||||
|
||||
df = getsmallrowdata_db(columns,ids=ids,doclean=True,workstrokesonly=workstrokesonly)
|
||||
|
||||
if df.empty:
|
||||
@@ -107,6 +107,7 @@ def alert_get_stats(alert,nperiod=0):
|
||||
'enddate':enddate,
|
||||
'nr_strokes':0,
|
||||
'nr_strokes_qualifying':0,
|
||||
'percentage':0,
|
||||
}
|
||||
|
||||
# check if filters are in columns list
|
||||
@@ -137,6 +138,7 @@ def alert_get_stats(alert,nperiod=0):
|
||||
'enddate':enddate,
|
||||
'nr_strokes':0,
|
||||
'nr_strokes_qualifying':0,
|
||||
'percentage':0,
|
||||
}
|
||||
|
||||
|
||||
@@ -160,13 +162,19 @@ def alert_get_stats(alert,nperiod=0):
|
||||
df2 = df[mask].copy()
|
||||
|
||||
nr_strokes_qualifying = len(df2)
|
||||
|
||||
if nr_strokes > 0:
|
||||
percentage = int(100.*nr_strokes_qualifying/nr_strokes)
|
||||
else:
|
||||
percentage = 0
|
||||
|
||||
return {
|
||||
'workouts':len(workouts),
|
||||
'startdate':startdate,
|
||||
'enddate':enddate,
|
||||
'nr_strokes':nr_strokes,
|
||||
'nr_strokes_qualifying':nr_strokes_qualifying
|
||||
'nr_strokes_qualifying':nr_strokes_qualifying,
|
||||
'percentage': percentage,
|
||||
}
|
||||
|
||||
# run alert report
|
||||
|
||||
Reference in New Issue
Block a user