Add duration sparkline on user workouts accordion
This commit is contained in:
10
app.py
10
app.py
@@ -222,6 +222,8 @@ def render_users_and_workouts():
|
||||
start_date = workouts[-1]['start_time_date'].date()
|
||||
# get end date from first workout
|
||||
end_date = workouts[0]['start_time_date'].date()
|
||||
# get difference in days between start and end date
|
||||
num_days = (end_date - start_date).days + 1
|
||||
# calculate number of weeks between start and end date
|
||||
num_weeks = (end_date - start_date).days // 7 + 1
|
||||
|
||||
@@ -241,7 +243,8 @@ def render_users_and_workouts():
|
||||
|
||||
workout_counts_sparkline = sparklines.sparklines(
|
||||
workout_counts_by_week)
|
||||
duration_sparkline = sparklines.sparklines(duration_by_week)
|
||||
duration_sparkline = sparklines.sparklines(
|
||||
[int(w['duration_minutes']) for w in workouts])[0]
|
||||
|
||||
user_data = {
|
||||
'id': user.id,
|
||||
@@ -250,7 +253,10 @@ def render_users_and_workouts():
|
||||
'workouts_count': len(workouts),
|
||||
'workouts': workouts,
|
||||
'workout_counts_by_week': workout_counts_by_week,
|
||||
'duration_by_week': duration_by_week
|
||||
'duration_by_week': duration_by_week,
|
||||
'num_days': num_days,
|
||||
'workout_counts_sparkline': workout_counts_sparkline,
|
||||
'duration_sparkline': duration_sparkline
|
||||
}
|
||||
users_data.append(user_data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user