Private
Public Access
1
0

manually adding ranking pieces works

This commit is contained in:
Sander Roosendaal
2017-11-18 17:38:01 -07:00
parent b21c0c122f
commit ec287cc4b5
2 changed files with 38 additions and 12 deletions

View File

@@ -556,16 +556,15 @@ def fetchcp(rower,theworkouts,table='cpdata'):
# create a new workout from manually entered data
def create_row_df(distance,duration,startdatetime):
def create_row_df(r,distance,duration,startdatetime,
title = 'Manually added workout',notes='',
workouttype='rower'):
print startdatetime
nr_strokes = int(distance/10.)
unixstarttime = arrow.get(startdatetime).timestamp
print unixstarttime,'aap'
totalseconds = duration.hour*3600.
totalseconds += duration.minute*60.
totalseconds += duration.second
@@ -584,19 +583,42 @@ def create_row_df(distance,duration,startdatetime):
unixtime = unixstarttime + elapsed
print unixtime
pace = 500.*totalseconds/distance
if workouttype in ['rower','slides','dynamic']:
velo = distance/totalseconds
power = 2.8*velo**3
else:
power = 0
df = pd.DataFrame({
'TimeStamp (sec)': unixtime,
' Horizontal (meters)': d,
' Cadence (stokes/min)': spm,
' Stroke500mPace (sec/500m)':pace,
' ElapsedTime (sec)':elapsed,
' Power (watts)':power,
})
return df
timestr = strftime("%Y%m%d-%H%M%S")
csvfilename = 'media/df_' + timestr + '.csv'
df[' ElapsedTime (sec)'] = df['TimeStamp (sec)']
row = rrdata(df=df)
row.write_csv(csvfilename, gzip = True)
id, message = save_workout_database(csvfilename, r,
title=title,
notes=notes,
dosmooth=False,
workouttype=workouttype,
consistencychecks=False,
totaltime=totalseconds)
return (id, message)
# Processes painsled CSV file to database