API & Client - refacto + handle null values
This commit is contained in:
parent
4af294cd4a
commit
01ee50c50c
@ -200,21 +200,21 @@ class Workout(BaseModel):
|
||||
'creation_date': self.creation_date,
|
||||
'modification_date': self.modification_date,
|
||||
'workout_date': self.workout_date,
|
||||
'duration': str(self.duration) if self.duration else None,
|
||||
'duration': None if self.duration is None else str(self.duration),
|
||||
'pauses': str(self.pauses) if self.pauses else None,
|
||||
'moving': str(self.moving) if self.moving else None,
|
||||
'distance': float(self.distance) if self.distance else None,
|
||||
'min_alt': float(self.min_alt) if self.min_alt else None,
|
||||
'max_alt': float(self.max_alt) if self.max_alt else None,
|
||||
'descent': float(self.descent)
|
||||
if self.descent is not None
|
||||
else None,
|
||||
'ascent': float(self.ascent) if self.ascent is not None else None,
|
||||
'moving': None if self.moving is None else str(self.moving),
|
||||
'distance': (
|
||||
None if self.distance is None else float(self.distance)
|
||||
),
|
||||
'min_alt': None if self.min_alt is None else float(self.min_alt),
|
||||
'max_alt': None if self.max_alt is None else float(self.max_alt),
|
||||
'descent': None if self.descent is None else float(self.descent),
|
||||
'ascent': None if self.ascent is None else float(self.ascent),
|
||||
'max_speed': (
|
||||
float(self.max_speed) if self.max_speed is not None else None
|
||||
None if self.max_speed is None else float(self.max_speed)
|
||||
),
|
||||
'ave_speed': (
|
||||
float(self.ave_speed) if self.ave_speed is not None else None
|
||||
None if self.ave_speed is None else float(self.ave_speed)
|
||||
),
|
||||
'records': [record.serialize() for record in self.records],
|
||||
'segments': [segment.serialize() for segment in self.segments],
|
||||
|
@ -12,7 +12,7 @@
|
||||
<span class="value">{{ workoutObject.duration }})</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="workout-data">
|
||||
<div class="workout-data" v-if="workoutObject.distance !== null">
|
||||
<i class="fa fa-road" aria-hidden="true" />
|
||||
<span class="label"> {{ $t('workouts.DISTANCE') }} </span>:
|
||||
<Distance
|
||||
|
@ -98,6 +98,7 @@
|
||||
{{ $t('workouts.DISTANCE') }}
|
||||
</span>
|
||||
<Distance
|
||||
v-if="workout.distance !== null"
|
||||
:distance="workout.distance"
|
||||
unitFrom="km"
|
||||
:useImperialUnits="user.imperial_units"
|
||||
@ -114,6 +115,7 @@
|
||||
{{ $t('workouts.AVE_SPEED') }}
|
||||
</span>
|
||||
<Distance
|
||||
v-if="workout.ave_speed !== null"
|
||||
:distance="workout.ave_speed"
|
||||
unitFrom="km"
|
||||
:speed="true"
|
||||
@ -125,6 +127,7 @@
|
||||
{{ $t('workouts.MAX_SPEED') }}
|
||||
</span>
|
||||
<Distance
|
||||
v-if="workout.max_speed !== null"
|
||||
:distance="workout.max_speed"
|
||||
unitFrom="km"
|
||||
:speed="true"
|
||||
|
@ -55,19 +55,19 @@ export interface IWeather {
|
||||
|
||||
export interface IWorkout {
|
||||
ascent: number | null
|
||||
ave_speed: number
|
||||
ave_speed: number | null
|
||||
bounds: number[]
|
||||
creation_date: string
|
||||
descent: number | null
|
||||
distance: number
|
||||
duration: string
|
||||
distance: number | null
|
||||
duration: string | null
|
||||
id: string
|
||||
map: string | null
|
||||
max_alt: number | null
|
||||
max_speed: number
|
||||
max_speed: number | null
|
||||
min_alt: number | null
|
||||
modification_date: string | null
|
||||
moving: string
|
||||
moving: string | null
|
||||
next_workout: string | null
|
||||
notes: string
|
||||
pauses: string | null
|
||||
@ -87,12 +87,12 @@ export interface IWorkoutObject {
|
||||
ascent: number | null
|
||||
aveSpeed: number | null
|
||||
descent: number | null
|
||||
distance: number
|
||||
duration: string
|
||||
distance: number | null
|
||||
duration: string | null
|
||||
maxAlt: number | null
|
||||
maxSpeed: number | null
|
||||
minAlt: number | null
|
||||
moving: string
|
||||
moving: string | null
|
||||
nextUrl: string | null
|
||||
pauses: string | null
|
||||
previousUrl: string | null
|
||||
|
Loading…
Reference in New Issue
Block a user