API & Client - fix elevation conversion to imperial units
This commit is contained in:
parent
47ec18e0a3
commit
3be55ed8e7
@ -0,0 +1,78 @@
|
||||
"""update elevation precision
|
||||
|
||||
Revision ID: 0f375c44e659
|
||||
Revises: a8cc0adfe1d3
|
||||
Create Date: 2022-12-14 18:01:54.662987
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0f375c44e659'
|
||||
down_revision = 'a8cc0adfe1d3'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.alter_column(
|
||||
'workouts',
|
||||
'descent',
|
||||
existing_type=sa.NUMERIC(precision=7, scale=2),
|
||||
type_=sa.Numeric(precision=8, scale=3),
|
||||
existing_nullable=True,
|
||||
)
|
||||
op.alter_column(
|
||||
'workouts',
|
||||
'ascent',
|
||||
existing_type=sa.NUMERIC(precision=7, scale=3),
|
||||
type_=sa.Numeric(precision=8, scale=3),
|
||||
existing_nullable=True,
|
||||
)
|
||||
op.alter_column(
|
||||
'workout_segments',
|
||||
'descent',
|
||||
existing_type=sa.NUMERIC(precision=7, scale=2),
|
||||
type_=sa.Numeric(precision=8, scale=3),
|
||||
existing_nullable=True,
|
||||
)
|
||||
op.alter_column(
|
||||
'workout_segments',
|
||||
'ascent',
|
||||
existing_type=sa.NUMERIC(precision=7, scale=3),
|
||||
type_=sa.Numeric(precision=8, scale=3),
|
||||
existing_nullable=True,
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.alter_column(
|
||||
'workout_segments',
|
||||
'ascent',
|
||||
existing_type=sa.NUMERIC(precision=8, scale=3),
|
||||
type_=sa.Numeric(precision=7, scale=2),
|
||||
existing_nullable=True,
|
||||
)
|
||||
op.alter_column(
|
||||
'workout_segments',
|
||||
'descent',
|
||||
existing_type=sa.NUMERIC(precision=8, scale=3),
|
||||
type_=sa.Numeric(precision=7, scale=2),
|
||||
existing_nullable=True,
|
||||
)
|
||||
op.alter_column(
|
||||
'workouts',
|
||||
'ascent',
|
||||
existing_type=sa.NUMERIC(precision=8, scale=3),
|
||||
type_=sa.Numeric(precision=7, scale=2),
|
||||
existing_nullable=True,
|
||||
)
|
||||
op.alter_column(
|
||||
'workouts',
|
||||
'descent',
|
||||
existing_type=sa.NUMERIC(precision=8, scale=3),
|
||||
type_=sa.Numeric(precision=7, scale=2),
|
||||
existing_nullable=True,
|
||||
)
|
@ -148,8 +148,8 @@ class Workout(BaseModel):
|
||||
distance = db.Column(db.Numeric(6, 3), nullable=True) # kilometers
|
||||
min_alt = db.Column(db.Numeric(6, 2), nullable=True) # meters
|
||||
max_alt = db.Column(db.Numeric(6, 2), nullable=True) # meters
|
||||
descent = db.Column(db.Numeric(7, 2), nullable=True) # meters
|
||||
ascent = db.Column(db.Numeric(7, 2), nullable=True) # meters
|
||||
descent = db.Column(db.Numeric(8, 3), nullable=True) # meters
|
||||
ascent = db.Column(db.Numeric(8, 3), nullable=True) # meters
|
||||
max_speed = db.Column(db.Numeric(6, 2), nullable=True) # km/h
|
||||
ave_speed = db.Column(db.Numeric(6, 2), nullable=True) # km/h
|
||||
bounds = db.Column(postgresql.ARRAY(db.Float), nullable=True)
|
||||
@ -415,8 +415,8 @@ class WorkoutSegment(BaseModel):
|
||||
distance = db.Column(db.Numeric(6, 3), nullable=True) # kilometers
|
||||
min_alt = db.Column(db.Numeric(6, 2), nullable=True) # meters
|
||||
max_alt = db.Column(db.Numeric(6, 2), nullable=True) # meters
|
||||
descent = db.Column(db.Numeric(7, 2), nullable=True) # meters
|
||||
ascent = db.Column(db.Numeric(7, 2), nullable=True) # meters
|
||||
descent = db.Column(db.Numeric(8, 3), nullable=True) # meters
|
||||
ascent = db.Column(db.Numeric(8, 3), nullable=True) # meters
|
||||
max_speed = db.Column(db.Numeric(6, 2), nullable=True) # km/h
|
||||
ave_speed = db.Column(db.Numeric(6, 2), nullable=True) # km/h
|
||||
|
||||
|
@ -439,13 +439,13 @@
|
||||
workoutForm.workoutAscent === ''
|
||||
? null
|
||||
: authUser.value.imperial_units
|
||||
? convertDistance(+workoutForm.workoutAscent, 'ft', 'm', 2)
|
||||
? convertDistance(+workoutForm.workoutAscent, 'ft', 'm', 3)
|
||||
: +workoutForm.workoutAscent
|
||||
payload.descent =
|
||||
workoutForm.workoutDescent === ''
|
||||
? null
|
||||
: authUser.value.imperial_units
|
||||
? convertDistance(+workoutForm.workoutDescent, 'ft', 'm', 2)
|
||||
? convertDistance(+workoutForm.workoutDescent, 'ft', 'm', 3)
|
||||
: +workoutForm.workoutDescent
|
||||
if (
|
||||
(payload.ascent !== null && payload.descent === null) ||
|
||||
|
Loading…
Reference in New Issue
Block a user