Add elevation in stats and dashboard and update translations

This commit is contained in:
antoine 2021-08-20 07:35:50 +02:00 committed by Sam
parent e7708b9ece
commit 660190d368
11 changed files with 112 additions and 13 deletions

View File

@ -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'
@ -120,7 +130,14 @@ def get_workouts(
workouts_list_by_time[time_period][sport_id][
'total_duration'
] += 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': {

View File

@ -53,6 +53,24 @@ export default class StatsCharts extends React.PureComponent {
/>
{t('statistics:duration')}
</label>
<label className="radioLabel col">
<input
type="radio"
name="ascent"
checked={displayedData === 'ascent'}
onChange={e => this.handleRadioChange(e)}
/>
{t('statistics:ascent')}
</label>
<label className="radioLabel col">
<input
type="radio"
name="descent"
checked={displayedData === 'descent'}
onChange={e => this.handleRadioChange(e)}
/>
{t('statistics:descent')}
</label>
<label className="radioLabel col">
<input
type="radio"

View File

@ -43,7 +43,25 @@ export default function WorkoutCard(props) {
)}
<i className="fa fa-road" aria-hidden="true" />{' '}
{t('workouts:Distance')}: {workout.distance} km
<br />
</p>
{workout.min_alt && workout.max_alt && (
<p>
<i className="fi-mountains custom-fa" />
{t('workouts:Min. altitude')}: {workout.min_alt}m
<br />
{t('workouts:Max. altitude')}: {workout.max_alt}m
<br />
</p>
)}
{workout.ascent && workout.descent && (
<p>
<i className="fa fa-location-arrow custom-fa" />
{t('workouts:Ascent')}: {workout.ascent}m
<br />
{t('workouts:Descent')}: {workout.descent}m
</p>
)}
</div>
</div>
</div>

View File

@ -21,6 +21,8 @@ export default class WorkoutsList extends React.PureComponent {
<th scope="col">{t('workouts:Duration')}</th>
<th scope="col">{t('workouts:Ave. speed')}</th>
<th scope="col">{t('workouts:Max. speed')}</th>
<th scope="col">{t('workouts:Ascent')}</th>
<th scope="col">{t('workouts:Descent')}</th>
</tr>
</thead>
<tbody>
@ -85,6 +87,18 @@ export default class WorkoutsList extends React.PureComponent {
</span>
{workout.max_speed} km/h
</td>
<td className="text-right">
<span className="heading-span-absolute">
{t('workouts:Ascent')}
</span>
{workout.ascent} m
</td>
<td className="text-right">
<span className="heading-span-absolute">
{t('workouts:Descent')}
</span>
{workout.descent} m
</td>
</tr>
))}
</tbody>

View File

@ -3,6 +3,11 @@
"Cycling (Transport)": "Cycling (Transport)",
"Hiking": "Hiking",
"Mountain Biking": "Mountain Biking",
"Mountain Biking (Electric)": "Mountain Biking (Electric)",
"Running": "Running",
"Walking": "Walking"
"Walking": "Walking",
"Trail" : "Trail",
"Skiing (Alpine)" : "Skiing (Alpine)",
"Skiing (Cross Country)" : "Skiing (Cross Country)",
"Rowing" : "Rowing"
}

View File

@ -2,6 +2,8 @@
"workouts": "workouts",
"distance": "distance",
"duration": "duration",
"ascent": "ascent",
"descent": "descent",
"month": "month",
"Statistics": "Statistics",
"year": "year",

View File

@ -3,6 +3,11 @@
"Cycling (Transport)": "Vélo (Transport)",
"Hiking": "Randonnée",
"Mountain Biking": "VTT",
"Mountain Biking (Electric)": "VTT (Electrique)",
"Running": "Course",
"Walking": "Marche"
"Walking": "Marche",
"Trail" : "Trail",
"Skiing (Alpine)" : "Ski (Alpin)",
"Skiing (Cross Country)" : "Ski (Randonnée)",
"Rowing" : "Aviron"
}

View File

@ -2,6 +2,8 @@
"workouts": "séances",
"distance": "distance",
"duration": "durée",
"ascent": "dénivelé+",
"descent": "dénivelé-",
"month": "mois",
"Statistics": "Statistiques",
"year": "année",

View File

@ -5,13 +5,13 @@
"Add a workout": "Ajouter une séance",
"Are you sure you want to delete this workout?": "Etes-vous sûr de vouloir supprimer cette séance ?",
"Ave. speed": "Vitesse moyenne",
"Ascent": "Dénivelé positif",
"Ascent": "Dénivelé +",
"Average speed": "Vitesse moyenne",
"Chart": "Analyse",
"data from gpx, without any cleaning": "données issues du fichier gpx, sans correction",
"Date": "Date",
"Delete workout": "Supprimer l'séance",
"Descent": "Dénivelé négatif",
"Descent": "Dénivelé -",
"Distance": "Distance",
"distance": "distance",
"Duration": "Durée",

View File

@ -39,6 +39,10 @@ export const formatValue = (displayedData, value) =>
? `${value.toFixed(2)} km`
: displayedData === 'duration'
? formatDuration(value)
: displayedData === 'ascent'
? `${value.toFixed(2)} km`
: displayedData === 'descent'
? `${value.toFixed(2)} km`
: value
const dateIncrement = (duration, day) => {
@ -69,6 +73,8 @@ export const formatStats = (stats, sports, params, displayedSports, weekm) => {
const nbWorkoutsStats = []
const distanceStats = []
const durationStats = []
const ascentStats = []
const descentStats = []
for (
let day = startDate(params.duration, params.start, weekm);
@ -83,6 +89,8 @@ export const formatStats = (stats, sports, params, displayedSports, weekm) => {
const dataNbWorkouts = { date: xAxis }
const dataDistance = { date: xAxis }
const dataDuration = { date: xAxis }
const dataAscent = { date: xAxis }
const dataDescent = { date: xAxis }
if (stats[date]) {
Object.keys(stats[date])
@ -94,17 +102,23 @@ export const formatStats = (stats, sports, params, displayedSports, weekm) => {
dataNbWorkouts[sportLabel] = stats[date][sportId].nb_workouts
dataDistance[sportLabel] = stats[date][sportId].total_distance
dataDuration[sportLabel] = stats[date][sportId].total_duration
dataAscent[sportLabel] = stats[date][sportId].total_ascent
dataDescent[sportLabel] = stats[date][sportId].total_descent
return null
})
}
nbWorkoutsStats.push(dataNbWorkouts)
distanceStats.push(dataDistance)
durationStats.push(dataDuration)
ascentStats.push(dataAscent)
descentStats.push(dataDescent)
}
return {
workouts: nbWorkoutsStats,
distance: distanceStats,
duration: durationStats,
ascent: ascentStats,
descent: descentStats,
}
}

View File

@ -4,13 +4,17 @@ import togeojson from '@mapbox/togeojson'
import { getDateWithTZ } from './index'
export const workoutColors = [
'#55a8a3',
'#98C3A9',
'#D0838A',
'#ECC77E',
'#926692',
'#929292',
'#428bca',
'#F94144',
'#F3722C',
'#F8961E',
'#F9844A',
'#F9C74F',
'#90BE6D',
'#43AA8B',
'#4D908E',
'#577590',
'#277DA1',
'#272DA1',
]
export const recordsLabels = [