Private
Public Access
1
0

added test for c2 auto import

This commit is contained in:
Sander Roosendaal
2021-01-19 06:00:55 +01:00
parent f42b20222c
commit add37be25b
3 changed files with 33 additions and 14 deletions

View File

@@ -159,7 +159,7 @@ def add_stroke_data(user,c2id,workoutid,startdatetime,csvfilename,
return 1
def get_c2_workouts(rower):
def get_c2_workouts(rower,do_async=True):
try:
thetoken = c2_open(rower.user)
except NoTokenError:
@@ -188,15 +188,17 @@ def get_c2_workouts(rower):
newids = [c2id for c2id in c2ids if not c2id in knownc2ids]
for c2id in newids:
res = myqueue(queuehigh,
handle_c2_async_workout,
alldata,
rower.user.id,
rower.c2token,
c2id,
)
#workoutid = create_async_workout(alldata,
# rower.user,c2id)
if do_async:
res = myqueue(queuehigh,
handle_c2_async_workout,
alldata,
rower.user.id,
rower.c2token,
c2id,
)
else:
workoutid = create_async_workout(alldata,
rower.user,c2id)
return 1
@@ -364,7 +366,10 @@ def create_async_workout(alldata,user,c2id):
if response.status_code != 200:
return 0
workoutid = response.json()['id']
try:
workoutid = response.json()['id']
except KeyError:
workoutid = 1
return workoutid