Private
Public Access
1
0

bug fixes stravaimport & sporttracks data without distance

This commit is contained in:
Sander Roosendaal
2017-04-27 13:01:33 +02:00
parent a6cb3d5140
commit c7447c3fad
2 changed files with 23 additions and 6 deletions

View File

@@ -167,10 +167,12 @@ def get_strava_workout(user,stravaid):
try:
t = np.array(timejson.json()[0]['data'])
d = np.array(distancejson.json()[1]['data'])
nr_rows = len(t)
d = np.array(distancejson.json()[1]['data'])
if nr_rows == 0:
return (0,"Error: Time data had zero length")
except IndexError:
return (0,"Error: No Distance information in the Strava data")
except KeyError:
return (0,"something went wrong with the Strava import")
@@ -181,13 +183,17 @@ def get_strava_workout(user,stravaid):
try:
hr = np.array(hrjson.json()[1]['data'])
except IndexError,KeyError:
except IndexError:
hr = np.zeros(nr_rows)
except KeyError:
hr = np.zeros(nr_rows)
try:
velo = np.array(velojson.json()[1]['data'])
except IndexError,KeyError:
except IndexError:
velo = np.zeros(nr_rows)
except KeyError:
velo = np.zeros(nr_rows)
dt = np.diff(t).mean()
wsize = round(5./dt)
@@ -197,7 +203,10 @@ def get_strava_workout(user,stravaid):
try:
lat = coords[:,0]
lon = coords[:,1]
except IndexError,KeyError:
except IndexError:
lat = np.zeros(len(t))
lon = np.zeros(len(t))
except KeyError:
lat = np.zeros(len(t))
lon = np.zeros(len(t))