upload works partially
This commit is contained in:
@@ -211,6 +211,8 @@ def createunderarmourworkoutdata(w):
|
||||
duration += w.duration.minute*60
|
||||
duration += w.duration.second
|
||||
duration += +1.0e-6*w.duration.microsecond
|
||||
name = w.name
|
||||
notes = w.notes
|
||||
|
||||
# adding diff, trying to see if this is valid
|
||||
#t = row.df.ix[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)']
|
||||
@@ -235,61 +237,68 @@ def createunderarmourworkoutdata(w):
|
||||
except KeyError:
|
||||
haslatlon = 0
|
||||
|
||||
# short for debugging
|
||||
# t = t[:3]
|
||||
# d = d[:3]
|
||||
# lat = lat[:3]
|
||||
# hr = hr[:3]
|
||||
# lon = lon[:3]
|
||||
# spm = spm[:3]
|
||||
|
||||
# path data
|
||||
if haslatlon:
|
||||
locdata = []
|
||||
for e in zip(t,lat,lon):
|
||||
point = {'timestamp':e[0],
|
||||
'latitude':e[1],
|
||||
'longitude':e[2],
|
||||
'altitude':0,
|
||||
"type":"gps"}
|
||||
locdata.append(point)
|
||||
point = {
|
||||
'lat':e[1],
|
||||
'lng':e[2],
|
||||
'elevation':0,
|
||||
}
|
||||
locdata.append([e[0],point])
|
||||
|
||||
hrdata = []
|
||||
for e in zip(t,hr):
|
||||
point = {'timestamp':e[0],
|
||||
'heart_rate':e[1]
|
||||
}
|
||||
point = [e[0],
|
||||
e[1]
|
||||
]
|
||||
hrdata.append(point)
|
||||
|
||||
distancedata = []
|
||||
for e in zip(t,d):
|
||||
point = {'timestamp':e[0],
|
||||
'distance':e[1]
|
||||
}
|
||||
point = [e[0],
|
||||
e[1]
|
||||
]
|
||||
distancedata.append(point)
|
||||
|
||||
start_time = w.startdatetime.strftime("%a, %d %b %Y %H:%M:%S")
|
||||
spmdata = []
|
||||
for e in zip(t,spm):
|
||||
spmdata.append([e[0],e[1]])
|
||||
|
||||
if haslatlon:
|
||||
data = {
|
||||
"type": "Rowing",
|
||||
"start_time": start_time,
|
||||
"total_distance": int(w.distance),
|
||||
"duration": duration,
|
||||
"notes": w.notes,
|
||||
"average_heart_rate": averagehr,
|
||||
"path": locdata,
|
||||
"distance": distancedata,
|
||||
"heart_rate": hrdata,
|
||||
"post_to_twitter":"false",
|
||||
"post_to_facebook":"false",
|
||||
}
|
||||
else:
|
||||
data = {
|
||||
"type": "Rowing",
|
||||
"start_time": start_time,
|
||||
"total_distance": int(w.distance),
|
||||
"duration": duration,
|
||||
"notes": w.notes,
|
||||
"avg_heartrate": averagehr,
|
||||
"distance": distancedata,
|
||||
"heart_rate": hrdata,
|
||||
"post_to_twitter":"false",
|
||||
"post_to_facebook":"false",
|
||||
}
|
||||
start_time = w.startdatetime.isoformat()
|
||||
|
||||
timeseries = {
|
||||
"distance": distancedata,
|
||||
"heartrate": hrdata,
|
||||
"cadence": spmdata,
|
||||
}
|
||||
|
||||
aggregrates = {
|
||||
"elapsed_time_total": duration,
|
||||
"distance_total": max(d),
|
||||
"heartrate_avg": averagehr,
|
||||
}
|
||||
|
||||
# if haslatlon:
|
||||
# timeseries["position"] = locdata
|
||||
|
||||
data = {
|
||||
"name": name,
|
||||
"start_datetime": start_time,
|
||||
"time_series": timeseries,
|
||||
"start_locale_timezone": "Etc/UTC",
|
||||
"activity_type": "/v7.1/activity_type/128/",
|
||||
"notes": notes,
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user