split workout (bugs)
This commit is contained in:
@@ -820,6 +820,43 @@ def new_workout_from_file(r,f2,
|
||||
|
||||
return (id,message,f2)
|
||||
|
||||
def split_workout(r,parent,splitsecond,splitmode):
|
||||
data,row = getrowdata_db(id=parent.id)
|
||||
|
||||
data['time'] = data['time']/1000.
|
||||
|
||||
data1 = data[data['time']<=splitsecond].copy()
|
||||
data2 = data[data['time']>splitsecond].copy()
|
||||
|
||||
|
||||
messages = []
|
||||
ids = []
|
||||
|
||||
if 'keep first' in splitmode:
|
||||
id,message = new_workout_from_df(r,data1,
|
||||
title=parent.name+' First Part',
|
||||
parent=parent)
|
||||
messages.append(message)
|
||||
ids.append(id)
|
||||
if 'keep second' in splitmode:
|
||||
data2['cumdist'] = data2['cumdist'] - data2['cumdist'].min()
|
||||
data2['time'] = data2['time'] - data2['time'].min()
|
||||
id,message = new_workout_from_df(r,data2,
|
||||
title=parent.name+' Second Part',
|
||||
parent=parent)
|
||||
messages.append(message)
|
||||
ids.append(id)
|
||||
|
||||
if not 'keep original' in splitmode:
|
||||
if 'keep second' in splitmode or 'keep first' in splitmode:
|
||||
parent.delete()
|
||||
messages.append('Deleted Workout: '+parent.name)
|
||||
else:
|
||||
messages.append('That would delete your workout')
|
||||
ids.append(parent.id)
|
||||
|
||||
return ids,messages
|
||||
|
||||
# Create new workout from data frame and store it in the database
|
||||
# This routine should be used everywhere in views.py and mailprocessing.py
|
||||
# Currently there is code duplication
|
||||
@@ -853,6 +890,7 @@ def new_workout_from_df(r,df,
|
||||
|
||||
|
||||
df.rename(columns = columndict,inplace=True)
|
||||
|
||||
starttimeunix = mktime(startdatetime.utctimetuple())
|
||||
df[' ElapsedTime (sec)'] = df['TimeStamp (sec)']
|
||||
df['TimeStamp (sec)'] = df['TimeStamp (sec)']+starttimeunix
|
||||
|
||||
Reference in New Issue
Block a user