Private
Public Access
1
0

Merge branch 'release/v10.42'

This commit is contained in:
Sander Roosendaal
2019-10-31 15:15:35 +01:00
2 changed files with 135 additions and 104 deletions

View File

@@ -467,7 +467,7 @@ def createc2workoutdata_as_splits(w):
def createc2workoutdata(w): def createc2workoutdata(w):
filename = w.csvfilename filename = w.csvfilename
try: try:
row = rowingdata(filename) row = rowingdata(csvfile=filename)
except IOError: except IOError:
return 0 return 0
@@ -478,6 +478,32 @@ def createc2workoutdata(w):
averagehr = 0 averagehr = 0
maxhr = 0 maxhr = 0
# Calculate intervalstats
itime, idist, itype = row.intervalstats_values()
lapnames = row.df[' lapIdx'].unique()
nrintervals = len(itime)
if len(lapnames != nrintervals):
newlapnames = []
for name in lapnames:
newlapnames += [name,name]
lapnames = newlapnames
intervaldata = []
for i in range(nrintervals):
if itime[i]>0:
mask = (row.df[' lapIdx'] == lapnames[i]) & (row.df[' WorkoutState'] == itype[i])
spmav = int(row.df[' Cadence (stokes/min)'][mask].mean().astype(int))
hrav = int(row.df[' HRCur (bpm)'][mask].mean().astype(int))
intervaldict = {
'type': 'distance',
'time': int(10*itime[i]),
'distance': int(idist[i]),
'heart_rate': {
'average':hrav,
},
'stroke_rate': spmav,
}
intervaldata.append(intervaldict)
# adding diff, trying to see if this is valid # adding diff, trying to see if this is valid
t = 10*row.df.loc[:,'TimeStamp (sec)'].values-10*row.df.loc[:,'TimeStamp (sec)'].iloc[0] t = 10*row.df.loc[:,'TimeStamp (sec)'].values-10*row.df.loc[:,'TimeStamp (sec)'].iloc[0]
try: try:
@@ -542,19 +568,24 @@ def createc2workoutdata(w):
data = { data = {
"type": mytypes.c2mapping[workouttype], "type": mytypes.c2mapping[workouttype],
"date": w.startdatetime.isoformat(), "date": w.startdatetime.isoformat(),
"stroke_count": int(row.stroke_count),
"timezone": w.timezone, "timezone": w.timezone,
"distance": int(w.distance), "distance": int(w.distance),
"time": int(10*makeseconds(durationstr)), "time": int(10*makeseconds(durationstr)),
"weight_class": c2wc(w.weightcategory), "weight_class": c2wc(w.weightcategory),
"comments": w.notes, "comments": w.notes,
'stroke_rate': int(row.df[' Cadence (stokes/min)'].mean()),
'drag_factor': int(row.dragfactor),
"heart_rate": { "heart_rate": {
"average": averagehr, "average": averagehr,
"max": maxhr, "max": maxhr,
}, },
"stroke_data": stroke_data, "stroke_data": stroke_data,
'workout': {
'splits': intervaldata,
}
} }
return data return data
# Refresh Concept2 authorization token # Refresh Concept2 authorization token

View File

@@ -708,7 +708,7 @@ def testdata(time,distance,pace,spm):
def getsmallrowdata_db(columns,ids=[],debug=False): def getsmallrowdata_db(columns,ids=[],debug=False):
csvfilenames = ['media/strokedata_{id}.parquet'.format(id=id) for id in ids] csvfilenames = ['media/strokedata_{id}.parquet.gz'.format(id=id) for id in ids]
data = [] data = []
columns = [c for c in columns if c != 'None'] columns = [c for c in columns if c != 'None']