Added total elevation to dashboard
This commit is contained in:
parent
eec1ef2efd
commit
8fa5d685cf
@ -120,7 +120,7 @@ class User(BaseModel):
|
||||
)
|
||||
total = (
|
||||
db.session.query(
|
||||
func.sum(Workout.distance), func.sum(Workout.duration)
|
||||
func.sum(Workout.distance), func.sum(Workout.duration), func.sum(Workout.ascent)
|
||||
)
|
||||
.filter(Workout.user_id == self.id)
|
||||
.first()
|
||||
@ -147,6 +147,7 @@ class User(BaseModel):
|
||||
],
|
||||
'total_distance': float(total[0]),
|
||||
'total_duration': str(total[1]),
|
||||
'total_ascent': str(total[2]),
|
||||
'imperial_units': self.imperial_units,
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,12 @@
|
||||
<StatCard
|
||||
icon="road"
|
||||
:value="totalDistance"
|
||||
:text="unitTo === 'mi' ? 'miles' : unitTo"
|
||||
:text="distanceUnitTo === 'mi' ? 'miles' : distanceUnitTo"
|
||||
/>
|
||||
<StatCard
|
||||
icon="arrow-circle-up"
|
||||
:value="totalAscent"
|
||||
:text="ascentUnitTo === 'ft' ? 'feet' : ascentUnitTo"
|
||||
/>
|
||||
<StatCard
|
||||
icon="clock-o"
|
||||
@ -43,13 +48,20 @@
|
||||
() => props.user.total_duration
|
||||
)
|
||||
const totalDuration = computed(() => get_duration(userTotalDuration))
|
||||
const defaultUnitFrom: TUnit = 'km'
|
||||
const unitTo: TUnit = user.value.imperial_units
|
||||
? units[defaultUnitFrom].defaultTarget
|
||||
: defaultUnitFrom
|
||||
const distanceUnitFrom: TUnit = 'km'
|
||||
const distanceUnitTo: TUnit = user.value.imperial_units
|
||||
? units[distanceUnitFrom].defaultTarget
|
||||
: distanceUnitFrom
|
||||
const totalDistance = user.value.imperial_units
|
||||
? convertDistance(user.value.total_distance, defaultUnitFrom, unitTo, 2)
|
||||
? convertDistance(user.value.total_distance, distanceUnitFrom, distanceUnitTo, 2)
|
||||
: parseFloat(user.value.total_distance.toFixed(2))
|
||||
const ascentUnitFrom: TUnit = 'm'
|
||||
const ascentUnitTo: TUnit = user.value.imperial_units
|
||||
? units[ascentUnitFrom].defaultTarget
|
||||
: ascentUnitFrom
|
||||
const totalAscent = user.value.imperial_units
|
||||
? convertDistance(user.value.total_ascent, ascentUnitFrom, ascentUnitTo, 2)
|
||||
: parseFloat(user.value.total_ascent.toFixed(2))
|
||||
|
||||
function get_duration(total_duration: ComputedRef<string>) {
|
||||
const duration = total_duration.value.match(/day/g)
|
||||
|
Loading…
Reference in New Issue
Block a user