diff --git a/fittrackee/migrations/versions/29_0f375c44e659_update_elevation_precision.py b/fittrackee/migrations/versions/29_0f375c44e659_update_elevation_precision.py new file mode 100644 index 00000000..27c44560 --- /dev/null +++ b/fittrackee/migrations/versions/29_0f375c44e659_update_elevation_precision.py @@ -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, + ) diff --git a/fittrackee/workouts/models.py b/fittrackee/workouts/models.py index fa488869..76252603 100644 --- a/fittrackee/workouts/models.py +++ b/fittrackee/workouts/models.py @@ -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 diff --git a/fittrackee_client/src/components/Workout/WorkoutEdition.vue b/fittrackee_client/src/components/Workout/WorkoutEdition.vue index 81326d48..55c3bc2d 100644 --- a/fittrackee_client/src/components/Workout/WorkoutEdition.vue +++ b/fittrackee_client/src/components/Workout/WorkoutEdition.vue @@ -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) ||