Private
Public Access
1
0

join working but needs improvement (form with title)

This commit is contained in:
Sander Roosendaal
2017-11-22 18:06:45 +01:00
parent 6a76ba05fa
commit 618e64579c
5 changed files with 269 additions and 3 deletions

View File

@@ -158,6 +158,69 @@ def filter_df(datadf, fieldname, value, largerthan=True):
return datadf
# joins workouts
def join_workouts(r,ids,title='Joined Workout',
parent=None,
setprivate=False,
forceunit='lbs'):
message = None
summary = ''
if parent:
oarlength = parent.oarlength
inboard = parent.inboard
workouttype = parent.workouttype
notes = parent.notes
summary = parent.summary
if parent.privacy == 'hidden':
makeprivate = True
else:
makeprivate = False
startdatetime = parent.startdatetime
else:
oarlength = 2.89
inboard = 0.88
workouttype = 'rower'
notes = ''
summary = ''
makeprivate = False
startdatetime = timezone.now()
if setprivate:
makeprivate = True
# reorder in chronological order
ws = Workout.objects.filter(id__in=ids).order_by("date", "starttime")
files = [w.csvfilename for w in ws]
row = rdata(files[0])
files = files[1:]
while len(files):
row2 = rdata(files[0])
if row2 != 0:
row = row+row2
files = files[1:]
timestr = strftime("%Y%m%d-%H%M%S")
csvfilename = 'media/df_' + timestr + '.csv'
row.write_csv(csvfilename,gzip=True)
id, message = save_workout_database(csvfilename, r,
workouttype=workouttype,
title=title,
notes=notes,
oarlength=oarlength,
inboard=inboard,
makeprivate=makeprivate,
dosmooth=False,
consistencychecks=False)
return (id, message)
def df_resample(datadf):
# time stamps must be in seconds