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