faster strava sync
This commit is contained in:
@@ -439,15 +439,19 @@ def createstravaworkoutdata(w,dozip=True):
|
||||
# Upload the TCX file to Strava and set the workout activity type
|
||||
# to rowing on Strava
|
||||
def handle_stravaexport(f2,workoutname,stravatoken,description='',
|
||||
activity_type='Rowing'):
|
||||
activity_type='Rowing',async=False):
|
||||
# w = Workout.objects.get(id=workoutid)
|
||||
client = stravalib.Client(access_token=stravatoken)
|
||||
|
||||
act = client.upload_activity(f2,'tcx.gz',name=workoutname)
|
||||
|
||||
try:
|
||||
res = act.wait(poll_interval=5.0,timeout=30)
|
||||
message = 'Workout successfully synchronized to Strava'
|
||||
if async:
|
||||
res = act.wait(poll_interval=1.0, timeout=10)
|
||||
message = 'Workout successfully synchronized to Strava'
|
||||
else:
|
||||
res = act.wait(poll_interval=5.0,timeout=30)
|
||||
message = 'Workout successfully synchronized to Strava'
|
||||
except:
|
||||
res = 0
|
||||
message = 'Strava upload timed out'
|
||||
@@ -621,7 +625,7 @@ def add_workout_from_data(user,importid,data,strokedata,
|
||||
|
||||
return id,message
|
||||
|
||||
def workout_strava_upload(user,w):
|
||||
def workout_strava_upload(user,w, async=False):
|
||||
try:
|
||||
thetoken = strava_open(user)
|
||||
except NoTokenError:
|
||||
@@ -644,7 +648,7 @@ def workout_strava_upload(user,w):
|
||||
f,w.name,
|
||||
r.stravatoken,
|
||||
description=w.notes+'\n from '+w.workoutsource+' via rowsandall.com',
|
||||
activity_type=r.stravaexportas)
|
||||
activity_type=r.stravaexportas,async=async)
|
||||
if res==0:
|
||||
message = mes
|
||||
w.uploadedtostrava = -1
|
||||
|
||||
Reference in New Issue
Block a user