Merge branch 'release/v18.8.10'
This commit is contained in:
@@ -1382,7 +1382,6 @@ class AnalysisChoiceForm(forms.Form):
|
|||||||
cpoverlay = forms.BooleanField(initial=False,
|
cpoverlay = forms.BooleanField(initial=False,
|
||||||
label='Overlay Gold Medal Performance',
|
label='Overlay Gold Medal Performance',
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
piece = forms.IntegerField(initial=4, label='Ranking Piece (minutes)',
|
piece = forms.IntegerField(initial=4, label='Ranking Piece (minutes)',
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
@@ -1393,6 +1392,9 @@ class AnalysisChoiceForm(forms.Form):
|
|||||||
trendline = forms.BooleanField(initial=False, required=False,
|
trendline = forms.BooleanField(initial=False, required=False,
|
||||||
label='Trend Line')
|
label='Trend Line')
|
||||||
|
|
||||||
|
savedata = forms.BooleanField(initial=False, required=False,
|
||||||
|
label='Export data as CSV')
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(AnalysisChoiceForm, self).__init__(*args, **kwargs)
|
super(AnalysisChoiceForm, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from rowers.views.statements import *
|
|||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
from rowers.rower_rules import can_view_session
|
from rowers.rower_rules import can_view_session
|
||||||
|
|
||||||
|
from django.forms.widgets import SelectDateWidget, HiddenInput
|
||||||
|
|
||||||
def floatformat(x, prec=2): # pragma: no cover
|
def floatformat(x, prec=2): # pragma: no cover
|
||||||
return '{x}'.format(x=round(x, prec))
|
return '{x}'.format(x=round(x, prec))
|
||||||
@@ -267,6 +268,37 @@ def analysis_new(request,
|
|||||||
request.session['enddate'] = enddatestring
|
request.session['enddate'] = enddatestring
|
||||||
request.session['options'] = options
|
request.session['options'] = options
|
||||||
|
|
||||||
|
savedata = options.get('savedata',False)
|
||||||
|
if savedata:
|
||||||
|
df = pd.DataFrame()
|
||||||
|
function = options.get('function','')
|
||||||
|
if function == 'boxplot':
|
||||||
|
df = boxplotdata(workouts, options)
|
||||||
|
elif function == 'trendflex': # pragma: no cover
|
||||||
|
df = trendflexdata(workouts, options, userid=userid)
|
||||||
|
elif function == 'histo': # pragma: no cover
|
||||||
|
df = histodata(workouts, options)
|
||||||
|
elif function == 'flexall': # pragma: no cover
|
||||||
|
df = flexalldata(workouts, options)
|
||||||
|
elif function == 'compare': # pragma: no cover
|
||||||
|
df = comparisondata(workouts, options)
|
||||||
|
elif function == 'cp': # pragma: no cover
|
||||||
|
df = cpdata(workouts, options)
|
||||||
|
options['savedata'] = False
|
||||||
|
request.session['options'] = options
|
||||||
|
response = HttpResponse(df.to_csv())
|
||||||
|
code = str(uuid4())
|
||||||
|
filename = code+'.csv'
|
||||||
|
chartform.fields['savedata'].initial = False
|
||||||
|
response['Content-Disposition'] = 'attachment; filename="%s"' % filename
|
||||||
|
response['Content-Type'] = 'application/octet-stream'
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
if not request.user.is_superuser:
|
||||||
|
chartform.fields['savedata'].widget = HiddenInput()
|
||||||
|
chartform.fields['savedata'].initial = False
|
||||||
|
|
||||||
breadcrumbs = [
|
breadcrumbs = [
|
||||||
{
|
{
|
||||||
'url': '/rowers/analysis',
|
'url': '/rowers/analysis',
|
||||||
@@ -315,6 +347,8 @@ def trendflexdata(workouts, options, userid=0):
|
|||||||
ids = options['ids']
|
ids = options['ids']
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
|
|
||||||
|
savedata = options.get('savedata',False)
|
||||||
|
|
||||||
|
|
||||||
fieldlist, fielddict = dataprep.getstatsfields()
|
fieldlist, fielddict = dataprep.getstatsfields()
|
||||||
fieldlist = [xparam, yparam, groupby,
|
fieldlist = [xparam, yparam, groupby,
|
||||||
@@ -466,6 +500,9 @@ def trendflexdata(workouts, options, userid=0):
|
|||||||
u = User.objects.get(id=userid)
|
u = User.objects.get(id=userid)
|
||||||
extratitle = ' '+u.first_name+' '+u.last_name
|
extratitle = ' '+u.first_name+' '+u.last_name
|
||||||
|
|
||||||
|
savedata = options.get('savedata',False)
|
||||||
|
if savedata:
|
||||||
|
return df
|
||||||
|
|
||||||
script, div = interactive_multiflex(df, xparam, yparam,
|
script, div = interactive_multiflex(df, xparam, yparam,
|
||||||
groupby,
|
groupby,
|
||||||
@@ -500,6 +537,19 @@ def flexalldata(workouts, options):
|
|||||||
u = User.objects.get(id=userid)
|
u = User.objects.get(id=userid)
|
||||||
extratitle = ' '+u.first_name+' '+u.last_name
|
extratitle = ' '+u.first_name+' '+u.last_name
|
||||||
|
|
||||||
|
savedata = options.get('savedata',False)
|
||||||
|
if savedata:
|
||||||
|
workstrokesonly = not includereststrokes
|
||||||
|
columns = [xparam, yparam1, yparam2, 'spm', 'driveenergy', 'distance']
|
||||||
|
ids = [int(w.id) for w in workouts]
|
||||||
|
df = dataprep.getsmallrowdata_db(columns, ids=ids,
|
||||||
|
workstrokesonly=workstrokesonly,
|
||||||
|
doclean=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
return df
|
||||||
|
|
||||||
|
|
||||||
res = interactive_cum_flex_chart2(workouts, xparam=xparam,
|
res = interactive_cum_flex_chart2(workouts, xparam=xparam,
|
||||||
yparam1=yparam1,
|
yparam1=yparam1,
|
||||||
yparam2=yparam2,
|
yparam2=yparam2,
|
||||||
@@ -532,6 +582,16 @@ def histodata(workouts, options):
|
|||||||
u = User.objects.get(id=userid)
|
u = User.objects.get(id=userid)
|
||||||
extratitle = ' '+u.first_name+' '+u.last_name
|
extratitle = ' '+u.first_name+' '+u.last_name
|
||||||
|
|
||||||
|
savedata = options.get('savedata',False)
|
||||||
|
if savedata:
|
||||||
|
workstrokesonly = not includereststrokes
|
||||||
|
ids = [int(w.id) for w in workouts]
|
||||||
|
df = dataprep.getsmallrowdata_db([plotfield], ids=ids,
|
||||||
|
workstrokesonly=workstrokesonly,
|
||||||
|
doclean=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
return df
|
||||||
|
|
||||||
script, div = interactive_histoall(workouts, plotfield, includereststrokes,
|
script, div = interactive_histoall(workouts, plotfield, includereststrokes,
|
||||||
spmmin=spmmin, spmmax=spmmax,
|
spmmin=spmmin, spmmax=spmmax,
|
||||||
@@ -562,9 +622,14 @@ def cpdata(workouts, options):
|
|||||||
'url': urls,
|
'url': urls,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
savedata = options.get('savedata',False)
|
||||||
|
if savedata:
|
||||||
|
return powerdf
|
||||||
|
|
||||||
if powerdf.empty: # pragma: no cover
|
if powerdf.empty: # pragma: no cover
|
||||||
return('', '<p>No valid data found</p>')
|
return('', '<p>No valid data found</p>')
|
||||||
|
|
||||||
|
|
||||||
powerdf = powerdf[powerdf['CP'] > 0]
|
powerdf = powerdf[powerdf['CP'] > 0]
|
||||||
powerdf.dropna(axis=0, inplace=True)
|
powerdf.dropna(axis=0, inplace=True)
|
||||||
powerdf.sort_values(['Delta', 'CP'], ascending=[1, 0], inplace=True)
|
powerdf.sort_values(['Delta', 'CP'], ascending=[1, 0], inplace=True)
|
||||||
@@ -786,6 +851,22 @@ def comparisondata(workouts, options):
|
|||||||
int(w.id): w.__str__() for w in workouts
|
int(w.id): w.__str__() for w in workouts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
savedata = options.get('savedata',False)
|
||||||
|
if savedata:
|
||||||
|
workstrokesonly = not includereststrokes
|
||||||
|
columns = [xparam, yparam1,
|
||||||
|
'ftime', 'distance', 'fpace',
|
||||||
|
'power', 'hr', 'spm',
|
||||||
|
'time', 'pace', 'workoutstate',
|
||||||
|
'workoutid']
|
||||||
|
|
||||||
|
df = dataprep.getsmallrowdata_db(columns, ids=ids,
|
||||||
|
workstrokesonly=workstrokesonly,
|
||||||
|
doclean=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
return df
|
||||||
|
|
||||||
res = interactive_multiple_compare_chart(ids, xparam, yparam1,
|
res = interactive_multiple_compare_chart(ids, xparam, yparam1,
|
||||||
promember=promember,
|
promember=promember,
|
||||||
plottype=plottype,
|
plottype=plottype,
|
||||||
@@ -852,6 +933,10 @@ def boxplotdata(workouts, options):
|
|||||||
u = User.objects.get(id=userid)
|
u = User.objects.get(id=userid)
|
||||||
extratitle = ' '+u.first_name+' '+u.last_name
|
extratitle = ' '+u.first_name+' '+u.last_name
|
||||||
|
|
||||||
|
savedata = options.get('savedata',False)
|
||||||
|
if savedata:
|
||||||
|
return datadf
|
||||||
|
|
||||||
script, div = interactive_boxchart(datadf, plotfield,
|
script, div = interactive_boxchart(datadf, plotfield,
|
||||||
extratitle=extratitle,
|
extratitle=extratitle,
|
||||||
spmmin=spmmin, spmmax=spmmax,
|
spmmin=spmmin, spmmax=spmmax,
|
||||||
@@ -908,6 +993,7 @@ def analysis_view_data(request, userid=0):
|
|||||||
except Workout.DoesNotExist: # pragma: no cover
|
except Workout.DoesNotExist: # pragma: no cover
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
if function == 'boxplot':
|
if function == 'boxplot':
|
||||||
script, div = boxplotdata(workouts, options)
|
script, div = boxplotdata(workouts, options)
|
||||||
elif function == 'trendflex': # pragma: no cover
|
elif function == 'trendflex': # pragma: no cover
|
||||||
|
|||||||
Reference in New Issue
Block a user