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