strava bug fixed
This commit is contained in:
@@ -322,7 +322,7 @@ def get_workout(user,stravaid):
|
|||||||
velo = get_strava_stream(r,'velocity_smooth',stravaid)
|
velo = get_strava_stream(r,'velocity_smooth',stravaid)
|
||||||
d = get_strava_stream(r,'distance',stravaid)
|
d = get_strava_stream(r,'distance',stravaid)
|
||||||
coords = get_strava_stream(r,'latlng',stravaid)
|
coords = get_strava_stream(r,'latlng',stravaid)
|
||||||
power = get_strava_stream(r,'power',stravaid)
|
power = get_strava_stream(r,'watts',stravaid)
|
||||||
|
|
||||||
if t is not None:
|
if t is not None:
|
||||||
nr_rows = len(t)
|
nr_rows = len(t)
|
||||||
@@ -388,6 +388,8 @@ def get_workout(user,stravaid):
|
|||||||
'strokelength':strokelength,
|
'strokelength':strokelength,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# startdatetime = datetime.datetime.strptime(startdatetime,"%Y-%m-%d-%H:%M:%S")
|
# startdatetime = datetime.datetime.strptime(startdatetime,"%Y-%m-%d-%H:%M:%S")
|
||||||
|
|
||||||
return [workoutsummary,df]
|
return [workoutsummary,df]
|
||||||
@@ -736,7 +738,7 @@ def handle_strava_import_stroke_data(title,
|
|||||||
velo = get_strava_stream(r,'velocity_smooth',stravaid)
|
velo = get_strava_stream(r,'velocity_smooth',stravaid)
|
||||||
d = get_strava_stream(r,'distance',stravaid)
|
d = get_strava_stream(r,'distance',stravaid)
|
||||||
coords = get_strava_stream(r,'latlng',stravaid)
|
coords = get_strava_stream(r,'latlng',stravaid)
|
||||||
power = get_strava_stream(r,'power',stravaid)
|
power = get_strava_stream(r,'watts',stravaid)
|
||||||
|
|
||||||
if t is not None:
|
if t is not None:
|
||||||
nr_rows = len(t)
|
nr_rows = len(t)
|
||||||
@@ -800,6 +802,9 @@ def handle_strava_import_stroke_data(title,
|
|||||||
|
|
||||||
strokedistance = 60.*velo2/spm
|
strokedistance = 60.*velo2/spm
|
||||||
|
|
||||||
|
if workouttype == 'rower' and pd.Series(power).mean() == 0:
|
||||||
|
power = 2.8*(velo2**3)
|
||||||
|
|
||||||
nr_strokes = len(t)
|
nr_strokes = len(t)
|
||||||
|
|
||||||
df = pd.DataFrame({'TimeStamp (sec)':unixtime,
|
df = pd.DataFrame({'TimeStamp (sec)':unixtime,
|
||||||
@@ -824,6 +829,8 @@ def handle_strava_import_stroke_data(title,
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
df.sort_values(by='TimeStamp (sec)',ascending=True)
|
df.sort_values(by='TimeStamp (sec)',ascending=True)
|
||||||
|
|
||||||
res = df.to_csv(csvfilename,index_label='index')
|
res = df.to_csv(csvfilename,index_label='index')
|
||||||
|
|||||||
@@ -474,6 +474,9 @@ def get_strava_stream(r,metric,stravaid,series_type='time',fetchresolution='high
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'resolution': 'medium',}
|
'resolution': 'medium',}
|
||||||
|
|
||||||
|
if metric == 'power':
|
||||||
|
metric = 'watts'
|
||||||
|
|
||||||
url = "https://www.strava.com/api/v3/activities/{stravaid}/streams/{metric}?resolution={fetchresolution}&series_type={series_type}".format(
|
url = "https://www.strava.com/api/v3/activities/{stravaid}/streams/{metric}?resolution={fetchresolution}&series_type={series_type}".format(
|
||||||
stravaid=stravaid,
|
stravaid=stravaid,
|
||||||
fetchresolution=fetchresolution,
|
fetchresolution=fetchresolution,
|
||||||
@@ -484,6 +487,12 @@ def get_strava_stream(r,metric,stravaid,series_type='time',fetchresolution='high
|
|||||||
|
|
||||||
s = requests.get(url,headers=headers)
|
s = requests.get(url,headers=headers)
|
||||||
|
|
||||||
|
|
||||||
|
if metric=='power':
|
||||||
|
with open('data.txt', 'w') as outfile:
|
||||||
|
json.dump(s.json(), outfile)
|
||||||
|
print('saved to file')
|
||||||
|
|
||||||
for data in s.json():
|
for data in s.json():
|
||||||
y = None
|
y = None
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user