diff --git a/fittrackee/__main__.py b/fittrackee/__main__.py index ee325e44..27bdde0b 100644 --- a/fittrackee/__main__.py +++ b/fittrackee/__main__.py @@ -8,11 +8,8 @@ import gunicorn.app.base from flask import Flask from flask_dramatiq import worker from flask_migrate import upgrade -from tqdm import tqdm from fittrackee import create_app, db -from fittrackee.workouts.models import Workout -from fittrackee.workouts.utils import update_workout HOST = os.getenv('HOST', '0.0.0.0') PORT = os.getenv('PORT', '5000') @@ -50,7 +47,7 @@ def upgrade_db() -> None: @app.cli.command('drop-db') def drop_db() -> None: - """Empty database for dev environments.""" + """Empty database and delete uploaded files for dev environments.""" db.engine.execute("DROP TABLE IF EXISTS alembic_version;") db.drop_all() db.session.commit() @@ -59,24 +56,6 @@ def drop_db() -> None: print('Uploaded files deleted.') -@app.cli.command() -def recalculate() -> None: - print("Starting workouts data refresh") - workouts = ( - Workout.query.filter(Workout.gpx != None) # noqa - .order_by(Workout.workout_date.asc()) # noqa - .all() - ) - if len(workouts) == 0: - print('➡️ no workouts to upgrade.') - return None - pbar = tqdm(workouts) - for workout in pbar: - update_workout(workout) - pbar.set_postfix(activitiy_id=workout.id) - db.session.commit() - - def main() -> None: options = {'bind': f'{HOST}:{PORT}', 'workers': WORKERS} StandaloneApplication(app, options).run() diff --git a/fittrackee/tests/workouts/test_workouts_api_2_patch.py b/fittrackee/tests/workouts/test_workouts_api_2_patch.py index f2589e98..45676536 100644 --- a/fittrackee/tests/workouts/test_workouts_api_2_patch.py +++ b/fittrackee/tests/workouts/test_workouts_api_2_patch.py @@ -7,7 +7,6 @@ from flask import Flask from fittrackee.users.models import User from fittrackee.workouts.models import Sport, Workout -from fittrackee.workouts.utils_id import decode_short_id from ..api_test_case import ApiTestCaseMixin from .utils import get_random_short_id, post_an_workout @@ -619,37 +618,3 @@ class TestEditWorkoutWithoutGpx(ApiTestCaseMixin): assert response.status_code == 404 assert 'not found' in data['status'] assert len(data['data']['workouts']) == 0 - - -class TestRefreshWorkoutWithGpx: - def test_refresh_an_workout_with_gpx( - self, - app: Flask, - user_1: User, - sport_1_cycling: Sport, - sport_2_running: Sport, - gpx_file: str, - ) -> None: - token, workout_short_id = post_an_workout(app, gpx_file) - workout_uuid = decode_short_id(workout_short_id) - client = app.test_client() - - # Edit some workout data - workout = Workout.query.filter_by(uuid=workout_uuid).first() - workout.ascent = 1000 - workout.min_alt = -100 - - response = client.patch( - f'/api/workouts/{workout_short_id}', - content_type='application/json', - data=json.dumps(dict(refresh=True)), - headers=dict(Authorization=f'Bearer {token}'), - ) - data = json.loads(response.data.decode()) - - assert response.status_code == 200 - assert 'success' in data['status'] - assert len(data['data']['workouts']) == 1 - assert 1 == data['data']['workouts'][0]['sport_id'] - assert 0.4 == data['data']['workouts'][0]['ascent'] - assert 975.0 == data['data']['workouts'][0]['min_alt'] diff --git a/fittrackee/workouts/utils.py b/fittrackee/workouts/utils.py index 3c9b463b..033be370 100644 --- a/fittrackee/workouts/utils.py +++ b/fittrackee/workouts/utils.py @@ -189,14 +189,12 @@ def edit_workout( workout: Workout, workout_data: Dict, auth_user: User ) -> Workout: """ - Edit an workout + Edit a workout Note: the gpx file is NOT modified In a next version, map_data and weather_data will be updated (case of a modified gpx file, see issue #7) """ - if workout_data.get('refresh'): - workout = update_workout(workout) if workout_data.get('sport_id'): workout.sport_id = workout_data.get('sport_id') if workout_data.get('title'): diff --git a/poetry.lock b/poetry.lock index 0a96a48e..9e05d55b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1206,22 +1206,6 @@ category = "dev" optional = false python-versions = ">=3.7" -[[package]] -name = "tqdm" -version = "4.62.3" -description = "Fast, Extensible Progress Meter" -category = "main" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" - -[package.dependencies] -colorama = {version = "*", markers = "platform_system == \"Windows\""} - -[package.extras] -dev = ["py-make (>=0.1.0)", "twine", "wheel"] -notebook = ["ipywidgets (>=6)"] -telegram = ["requests"] - [[package]] name = "trio" version = "0.19.0" @@ -1367,7 +1351,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest- [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "efbc9200e445df97c991ac1e6b72873262c32e0f09b21dc682593fd5034686ab" +content-hash = "ec6da4aaa4cef6ee6c235ef4d2f101b533409097ee8b5169596373a5b4c60cdb" [metadata.files] alabaster = [ @@ -2105,10 +2089,6 @@ tomli = [ {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] -tqdm = [ - {file = "tqdm-4.62.3-py2.py3-none-any.whl", hash = "sha256:8dd278a422499cd6b727e6ae4061c40b48fce8b76d1ccbf5d34fca9b7f925b0c"}, - {file = "tqdm-4.62.3.tar.gz", hash = "sha256:d359de7217506c9851b7869f3708d8ee53ed70a1b8edbba4dbcb47442592920d"}, -] trio = [ {file = "trio-0.19.0-py3-none-any.whl", hash = "sha256:c27c231e66336183c484fbfe080fa6cc954149366c15dc21db8b7290081ec7b8"}, {file = "trio-0.19.0.tar.gz", hash = "sha256:895e318e5ec5e8cea9f60b473b6edb95b215e82d99556a03eb2d20c5e027efe1"}, diff --git a/pyproject.toml b/pyproject.toml index e89a3d8a..658d89ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,6 @@ python-forecastio = "^1.4" pytz = "^2021.3" shortuuid = "^1.0.8" staticmap = "^0.5.4" -tqdm = "^4.62" SQLAlchemy = "1.4.31" pyOpenSSL = "^22.0"