added better user opening
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,6 +3,7 @@
|
||||
testcert.crt
|
||||
testcert.key
|
||||
garminlog.log
|
||||
strava_webhooks.log
|
||||
|
||||
# Compiled python modules.
|
||||
*.pyc
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user