bug fixes stravaimport & sporttracks data without distance
This commit is contained in:
@@ -167,10 +167,12 @@ def get_strava_workout(user,stravaid):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
t = np.array(timejson.json()[0]['data'])
|
t = np.array(timejson.json()[0]['data'])
|
||||||
d = np.array(distancejson.json()[1]['data'])
|
|
||||||
nr_rows = len(t)
|
nr_rows = len(t)
|
||||||
|
d = np.array(distancejson.json()[1]['data'])
|
||||||
if nr_rows == 0:
|
if nr_rows == 0:
|
||||||
return (0,"Error: Time data had zero length")
|
return (0,"Error: Time data had zero length")
|
||||||
|
except IndexError:
|
||||||
|
return (0,"Error: No Distance information in the Strava data")
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return (0,"something went wrong with the Strava import")
|
return (0,"something went wrong with the Strava import")
|
||||||
|
|
||||||
@@ -181,13 +183,17 @@ def get_strava_workout(user,stravaid):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
hr = np.array(hrjson.json()[1]['data'])
|
hr = np.array(hrjson.json()[1]['data'])
|
||||||
except IndexError,KeyError:
|
except IndexError:
|
||||||
|
hr = np.zeros(nr_rows)
|
||||||
|
except KeyError:
|
||||||
hr = np.zeros(nr_rows)
|
hr = np.zeros(nr_rows)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
velo = np.array(velojson.json()[1]['data'])
|
velo = np.array(velojson.json()[1]['data'])
|
||||||
except IndexError,KeyError:
|
except IndexError:
|
||||||
velo = np.zeros(nr_rows)
|
velo = np.zeros(nr_rows)
|
||||||
|
except KeyError:
|
||||||
|
velo = np.zeros(nr_rows)
|
||||||
|
|
||||||
dt = np.diff(t).mean()
|
dt = np.diff(t).mean()
|
||||||
wsize = round(5./dt)
|
wsize = round(5./dt)
|
||||||
@@ -197,7 +203,10 @@ def get_strava_workout(user,stravaid):
|
|||||||
try:
|
try:
|
||||||
lat = coords[:,0]
|
lat = coords[:,0]
|
||||||
lon = coords[:,1]
|
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))
|
lat = np.zeros(len(t))
|
||||||
lon = np.zeros(len(t))
|
lon = np.zeros(len(t))
|
||||||
|
|
||||||
|
|||||||
@@ -742,8 +742,10 @@ def add_workout_from_stdata(user,importid,data):
|
|||||||
except:
|
except:
|
||||||
title = "Imported data"
|
title = "Imported data"
|
||||||
|
|
||||||
|
try:
|
||||||
res = splitstdata(data['distance'])
|
res = splitstdata(data['distance'])
|
||||||
|
except KeyError:
|
||||||
|
return (0,"No distance data in the workout")
|
||||||
|
|
||||||
distance = res[1]
|
distance = res[1]
|
||||||
times_distance = res[0]
|
times_distance = res[0]
|
||||||
@@ -5582,6 +5584,12 @@ def workout_getsporttracksworkout_view(request,sporttracksid):
|
|||||||
data = res.json()
|
data = res.json()
|
||||||
|
|
||||||
id,message = add_workout_from_stdata(request.user,sporttracksid,data)
|
id,message = add_workout_from_stdata(request.user,sporttracksid,data)
|
||||||
|
if id==0:
|
||||||
|
url = reverse(workouts_view,
|
||||||
|
kwargs = {
|
||||||
|
'message':message,
|
||||||
|
})
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
w = Workout.objects.get(id=id)
|
w = Workout.objects.get(id=id)
|
||||||
w.uploadedtosporttracks=sporttracksid
|
w.uploadedtosporttracks=sporttracksid
|
||||||
w.save()
|
w.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user