Private
Public Access
1
0

hoping strava webhooks will work

This commit is contained in:
Sander Roosendaal
2020-07-12 13:20:13 +02:00
parent 3564a89e02
commit b85441f7eb
4 changed files with 26 additions and 22 deletions

View File

@@ -2713,7 +2713,7 @@ def add2(x, y,debug=False,**kwargs):
return x + y
@app.task
def fetch_strava_workout(stravatoken,oauth_data,workoutid,stravaid,csvfilename,debug=False,**kwargs):
def fetch_strava_workout(stravatoken,oauth_data,stravaid,csvfilename,userid,debug=False,**kwargs):
fetchresolution = 'high'
authorizationstring = str('Bearer '+stravatoken)
headers = {'Authorization': authorizationstring,
@@ -2925,19 +2925,30 @@ def fetch_strava_workout(stravatoken,oauth_data,workoutid,stravaid,csvfilename,d
df.sort_values(by='TimeStamp (sec)',ascending=True)
row = rowingdata.rowingdata(df=df)
row.write_csv(csvfilename,gzip=True)
row.write_csv(csvfilename,gzip=False)
summary = row.allstats()
maxdist = df['cum_dist'].max()
duration = row.duration
uploadoptions = {
'secret':UPLOAD_SERVICE_SECRET,
'user':userid,
'file': csvfilename,
'title': title,
'workouttype':workouttype,
'boattype':'1x',
'stravaid':stravaid,
}
print(uploadoptions)
session = requests.session()
newHeaders = {'Content-type': 'application/json', 'Accept': 'text/plain'}
session.headers.update(newHeaders)
response = session.post(UPLOAD_SERVICE_URL,json=uploadoptions)
update_strokedata(workoutid,row.df,debug=debug)
res = update_workout_field_sql(workoutid,'workouttype',workouttype,debug=debug)
res = update_workout_field_sql(workoutid,'name',title,debug=debug)
res = update_workout_field_sql(workoutid,'notes',comments,debug=debug)
res = update_workout_field_sql(workoutid,'summary',summary,debug=debug)
res = update_workout_field_sql(workoutid,'distance',maxdist,debug=debug)
res = update_workout_field_sql(workoutid,'duration',duration,debug=debug)
return 1