Dataprep upon upload
This commit is contained in:
@@ -156,10 +156,21 @@ def read_cols_df_sql(ids,col1,col2,col3):
|
|||||||
for column in columns:
|
for column in columns:
|
||||||
cls += column+', '
|
cls += column+', '
|
||||||
cls = cls[:-2]
|
cls = cls[:-2]
|
||||||
query = sa.text('SELECT {columns} FROM strokedata WHERE workoutid IN {ids}'.format(
|
if len(ids) == 0:
|
||||||
columns = cls,
|
query = sa.text('SELECT {columns} FROM strokedata WHERE workoutid=0'.format(
|
||||||
ids = tuple(ids),
|
columns = cls,
|
||||||
|
))
|
||||||
|
elif len(ids) == 1:
|
||||||
|
query = sa.text('SELECT {columns} FROM strokedata WHERE workoutid={id}'.format(
|
||||||
|
id = ids[0],
|
||||||
|
columns = cls,
|
||||||
|
))
|
||||||
|
else:
|
||||||
|
query = sa.text('SELECT {columns} FROM strokedata WHERE workoutid IN {ids}'.format(
|
||||||
|
columns = cls,
|
||||||
|
ids = tuple(ids),
|
||||||
))
|
))
|
||||||
|
|
||||||
df = pd.read_sql_query(query,engine)
|
df = pd.read_sql_query(query,engine)
|
||||||
return df
|
return df
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ def interactive_histoall(theworkouts):
|
|||||||
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,resize,crosshair'
|
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,resize,crosshair'
|
||||||
|
|
||||||
ids = [w.id for w in theworkouts]
|
ids = [w.id for w in theworkouts]
|
||||||
|
|
||||||
rowdata = dataprep.getsmallrowdata_db('power','power','power',ids=ids)
|
rowdata = dataprep.getsmallrowdata_db('power','power','power',ids=ids)
|
||||||
|
|
||||||
histopwr = rowdata['power'].values
|
histopwr = rowdata['power'].values
|
||||||
|
|||||||
@@ -2870,10 +2870,6 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
u = request.user
|
u = request.user
|
||||||
r = Rower.objects.get(user=u)
|
r = Rower.objects.get(user=u)
|
||||||
|
|
||||||
res = interactive_chart(id)
|
|
||||||
script = res[0]
|
|
||||||
div = res[1]
|
|
||||||
|
|
||||||
rowdata = rdata(f1)
|
rowdata = rdata(f1)
|
||||||
hascoordinates = 1
|
hascoordinates = 1
|
||||||
if rowdata != 0:
|
if rowdata != 0:
|
||||||
@@ -2906,8 +2902,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
'gmscript': gmscript,
|
'gmscript': gmscript,
|
||||||
'gmdiv': gmdiv,
|
'gmdiv': gmdiv,
|
||||||
})
|
})
|
||||||
# 'interactiveplot':script,
|
|
||||||
# 'the_div':div})
|
|
||||||
else:
|
else:
|
||||||
return render(request, 'workout_form.html',
|
return render(request, 'workout_form.html',
|
||||||
{'form':form,
|
{'form':form,
|
||||||
@@ -2919,8 +2914,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
'gmscript': gmscript,
|
'gmscript': gmscript,
|
||||||
'gmdiv': gmdiv,
|
'gmdiv': gmdiv,
|
||||||
})
|
})
|
||||||
# 'interactiveplot':script,
|
|
||||||
# 'the_div':div})
|
|
||||||
|
|
||||||
except Workout.DoesNotExist:
|
except Workout.DoesNotExist:
|
||||||
form = WorkoutForm(
|
form = WorkoutForm(
|
||||||
@@ -3658,6 +3652,8 @@ def workout_upload_view(request,message=""):
|
|||||||
startdatetime=workoutstartdatetime)
|
startdatetime=workoutstartdatetime)
|
||||||
|
|
||||||
w.save()
|
w.save()
|
||||||
|
# put stroke data in database
|
||||||
|
res = dataprep.dataprep(row.df,id=w.id,bands=True,barchart=True,otwpower=True)
|
||||||
|
|
||||||
# Make Plot
|
# Make Plot
|
||||||
if (make_plot):
|
if (make_plot):
|
||||||
|
|||||||
Reference in New Issue
Block a user