From 660190d368cd54aa0c9c149126abc0891e4ce0df Mon Sep 17 00:00:00 2001 From: antoine Date: Fri, 20 Aug 2021 07:35:50 +0200 Subject: [PATCH] Add elevation in stats and dashboard and update translations --- fittrackee/workouts/stats.py | 21 +++++++++++++++++-- .../components/Common/Stats/StatsChart.jsx | 18 ++++++++++++++++ .../src/components/Dashboard/WorkoutCard.jsx | 18 ++++++++++++++++ .../src/components/Workouts/WorkoutsList.jsx | 14 +++++++++++++ fittrackee_client/src/locales/en/sports.json | 7 ++++++- .../src/locales/en/statistics.json | 2 ++ fittrackee_client/src/locales/fr/sports.json | 7 ++++++- .../src/locales/fr/statistics.json | 2 ++ .../src/locales/fr/workouts.json | 4 ++-- fittrackee_client/src/utils/stats.js | 14 +++++++++++++ fittrackee_client/src/utils/workouts.js | 18 +++++++++------- 11 files changed, 112 insertions(+), 13 deletions(-) diff --git a/fittrackee/workouts/stats.py b/fittrackee/workouts/stats.py index 80de9480..de9a97a5 100644 --- a/fittrackee/workouts/stats.py +++ b/fittrackee/workouts/stats.py @@ -67,6 +67,8 @@ def get_workouts( 'nb_workouts': 0, 'total_distance': 0.0, 'total_duration': 0, + 'total_ascent': 0.0, + 'total_descent': 0.0, } workouts_list_by_sport[sport_id]['nb_workouts'] += 1 workouts_list_by_sport[sport_id]['total_distance'] += float( @@ -75,6 +77,12 @@ def get_workouts( workouts_list_by_sport[sport_id][ 'total_duration' ] += convert_timedelta_to_integer(workout.moving) + workouts_list_by_sport[sport_id]['total_ascent'] += float( + workout.ascent + ) + workouts_list_by_sport[sport_id]['total_descent'] += float( + workout.descent + ) # filter_type == 'by_time' else: @@ -110,6 +118,8 @@ def get_workouts( 'nb_workouts': 0, 'total_distance': 0.0, 'total_duration': 0, + 'total_ascent': 0.0, + 'total_descent': 0.0, } workouts_list_by_time[time_period][sport_id][ 'nb_workouts' @@ -119,8 +129,15 @@ def get_workouts( ] += float(workout.distance) workouts_list_by_time[time_period][sport_id][ 'total_duration' - ] += convert_timedelta_to_integer(workout.moving) - + ] += convert_timedelta_to_integer(workout.moving) + if workout.ascent: + workouts_list_by_time[time_period][sport_id][ + 'total_ascent' + ] += float(workout.ascent / 1000) + if workout.descent: + workouts_list_by_time[time_period][sport_id][ + 'total_descent' + ] += float(workout.descent / 1000) return { 'status': 'success', 'data': { diff --git a/fittrackee_client/src/components/Common/Stats/StatsChart.jsx b/fittrackee_client/src/components/Common/Stats/StatsChart.jsx index ca3678f1..1862b0d5 100644 --- a/fittrackee_client/src/components/Common/Stats/StatsChart.jsx +++ b/fittrackee_client/src/components/Common/Stats/StatsChart.jsx @@ -53,6 +53,24 @@ export default class StatsCharts extends React.PureComponent { /> {t('statistics:duration')} + +