diff --git a/rowers/alerts.py b/rowers/alerts.py index 0865d07e..fdf00366 100644 --- a/rowers/alerts.py +++ b/rowers/alerts.py @@ -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 diff --git a/rowers/templates/alerts.html b/rowers/templates/alerts.html index 20bb05de..e0cad516 100644 --- a/rowers/templates/alerts.html +++ b/rowers/templates/alerts.html @@ -12,6 +12,33 @@
+ {{ alert.description }} +
++ Workout type: {{ alert.workouttype }} +
++ Next Run: {{ alert.next_run }} +
+