From af00ed228048579d5d16c868f49bb6ac26e1ee23 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 19 Dec 2024 14:36:45 +0100 Subject: [PATCH] not working yet --- rowers/integrations/c2.py | 4 ++-- rowers/tasks.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/rowers/integrations/c2.py b/rowers/integrations/c2.py index c2d21332..8d950f18 100644 --- a/rowers/integrations/c2.py +++ b/rowers/integrations/c2.py @@ -20,7 +20,7 @@ from rowsandall_app.settings import ( from rowers.tasks import ( handle_c2_import_stroke_data, handle_c2_sync, handle_c2_async_workout, - handle_c2_getworkout + handle_c2_getworkout, handle_c2_getworkout_csv ) import django_rq queue = django_rq.get_queue('default') @@ -365,7 +365,7 @@ class C2Integration(SyncIntegration): record = create_or_update_syncrecord(r, None, c2id=id) _ = myqueue(queuehigh, - handle_c2_getworkout, + handle_c2_getworkout_csv, self.user.id, self.rower.c2token, id, diff --git a/rowers/tasks.py b/rowers/tasks.py index ebadcfee..95930f9a 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -3555,6 +3555,25 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, * return 1 +@app.task +def handle_c2_getworkout_csv(userid, c2token, c2id, defaulttimezone, debug=False, **kwargs): + authorizationstring = str('Bearer ' + c2token) + headers = {'Authorization': authorizationstring, + 'user-agent': 'sanderroosendaal', + 'Content-Type': 'application/json'} + url = "https://log.concept2.com/api/users/me/results/"+str(c2id)+"/export/fit" + + print(url) + print(c2token) + response = requests.get(url, headers=headers) + + if response.status_code != 200: + print(response.status_code, response.text) + return 0 + + # get the file from the content data + print(response.status_code,"aap") + @app.task def handle_c2_getworkout(userid, c2token, c2id, defaulttimezone, debug=False, **kwargs): authorizationstring = str('Bearer ' + c2token)