Check if weekly workouts is zero before calculating duratio by week to avoid division by zero error
This commit is contained in:
5
app.py
5
app.py
@@ -316,8 +316,9 @@ def render_users_and_workouts():
|
||||
|
||||
# Calculate the workout counts and duration for the current week
|
||||
workout_counts_by_week.append(len(weekly_workouts))
|
||||
duration_by_week.append(
|
||||
int(sum([int(w['duration_minutes']) for w in weekly_workouts]))/len(weekly_workouts))
|
||||
if weekly_workouts:
|
||||
duration_by_week.append(
|
||||
int(sum([int(w['duration_minutes']) for w in weekly_workouts]))/len(weekly_workouts))
|
||||
|
||||
workout_counts_sparkline = sparklines.sparklines(
|
||||
workout_counts_by_week)
|
||||
|
||||
Reference in New Issue
Block a user