Private
Public Access
1
0

added better user opening

This commit is contained in:
Sander Roosendaal
2020-07-12 16:47:11 +02:00
parent fb8ba401a8
commit d83de61d29
3 changed files with 10 additions and 1 deletions

1
.gitignore vendored
View File

@@ -3,6 +3,7 @@
testcert.crt
testcert.key
garminlog.log
strava_webhooks.log
# Compiled python modules.
*.pyc

View File

@@ -326,6 +326,7 @@ def create_async_workout(alldata,user,stravaid,debug=False):
from rowers.utils import get_strava_stream
def async_get_workout(user,stravaid):
token = strava_open(user)
csvfilename = 'media/{code}_{stravaid}.csv'.format(code=uuid4().hex[:16],stravaid=stravaid)
job = myqueue(queue,
fetch_strava_workout,

View File

@@ -2721,6 +2721,10 @@ def fetch_strava_workout(stravatoken,oauth_data,stravaid,csvfilename,userid,debu
'Content-Type': 'application/json',
'resolution': 'medium',}
url = "https://www.strava.com/api/v3/activities/"+str(stravaid)
response = requests.get(url,headers=headers)
if response.status_code != 200:
print(response,response.json())
return 0
workoutsummary = requests.get(url,headers=headers).json()
try:
startdatetime = workoutsummary['start_date']
@@ -2738,7 +2742,10 @@ def fetch_strava_workout(stravatoken,oauth_data,stravaid,csvfilename,userid,debu
if t is not None:
nr_rows = len(t)
else:
duration = int(workoutsummary['elapsed_time'])
try:
duration = int(workoutsummary['elapsed_time'])
except KeyError:
duration = 0
t = pd.Series(range(duration+1))
nr_rows = len(t)