manually adding ranking pieces works
This commit is contained in:
@@ -556,16 +556,15 @@ def fetchcp(rower,theworkouts,table='cpdata'):
|
|||||||
|
|
||||||
|
|
||||||
# create a new workout from manually entered data
|
# 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.)
|
nr_strokes = int(distance/10.)
|
||||||
|
|
||||||
unixstarttime = arrow.get(startdatetime).timestamp
|
unixstarttime = arrow.get(startdatetime).timestamp
|
||||||
|
|
||||||
print unixstarttime,'aap'
|
|
||||||
|
|
||||||
totalseconds = duration.hour*3600.
|
totalseconds = duration.hour*3600.
|
||||||
totalseconds += duration.minute*60.
|
totalseconds += duration.minute*60.
|
||||||
totalseconds += duration.second
|
totalseconds += duration.second
|
||||||
@@ -584,19 +583,42 @@ def create_row_df(distance,duration,startdatetime):
|
|||||||
|
|
||||||
unixtime = unixstarttime + elapsed
|
unixtime = unixstarttime + elapsed
|
||||||
|
|
||||||
print unixtime
|
|
||||||
|
|
||||||
pace = 500.*totalseconds/distance
|
pace = 500.*totalseconds/distance
|
||||||
|
|
||||||
|
if workouttype in ['rower','slides','dynamic']:
|
||||||
|
velo = distance/totalseconds
|
||||||
|
power = 2.8*velo**3
|
||||||
|
else:
|
||||||
|
power = 0
|
||||||
|
|
||||||
df = pd.DataFrame({
|
df = pd.DataFrame({
|
||||||
'TimeStamp (sec)': unixtime,
|
'TimeStamp (sec)': unixtime,
|
||||||
' Horizontal (meters)': d,
|
' Horizontal (meters)': d,
|
||||||
' Cadence (stokes/min)': spm,
|
' Cadence (stokes/min)': spm,
|
||||||
' Stroke500mPace (sec/500m)':pace,
|
' Stroke500mPace (sec/500m)':pace,
|
||||||
' ElapsedTime (sec)':elapsed,
|
' 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
|
# Processes painsled CSV file to database
|
||||||
|
|
||||||
|
|||||||
@@ -3135,12 +3135,16 @@ def addmanual_view(request):
|
|||||||
pytz.timezone(thetimezone)
|
pytz.timezone(thetimezone)
|
||||||
)
|
)
|
||||||
|
|
||||||
df = dataprep.create_row_df(distance,duration,startdatetime)
|
|
||||||
|
|
||||||
id,message = dataprep.new_workout_from_df(r,df,
|
print name
|
||||||
title = name,
|
id,message = dataprep.create_row_df(r,
|
||||||
parent = None,
|
distance,
|
||||||
)
|
duration,startdatetime,
|
||||||
|
title = name,
|
||||||
|
notes=notes,
|
||||||
|
workouttype=workouttype)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if message:
|
if message:
|
||||||
messages.error(request,message)
|
messages.error(request,message)
|
||||||
|
|||||||
Reference in New Issue
Block a user