Private
Public Access
1
0

additional metrics are available in flex chart

This commit is contained in:
Sander Roosendaal
2017-11-29 13:26:29 +01:00
parent 4e5b661923
commit a80df03d60
4 changed files with 97 additions and 70 deletions

View File

@@ -916,6 +916,16 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
w.startdatetime = timezone.now()
w.save()
if privacy == 'visible':
ts = Team.objects.filter(rower=r)
for t in ts:
w.team.add(t)
# put stroke data in database
res = dataprep(row.df, id=w.id, bands=True,
barchart=True, otwpower=True, empower=True, inboard=inboard)
isbreakthrough = False
ishard = False
if workouttype == 'water':
@@ -981,14 +991,6 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
else:
pass
if privacy == 'visible':
ts = Team.objects.filter(rower=r)
for t in ts:
w.team.add(t)
# put stroke data in database
res = dataprep(row.df, id=w.id, bands=True,
barchart=True, otwpower=True, empower=True, inboard=inboard)
return (w.id, message)
@@ -1150,14 +1152,6 @@ def new_workout_from_file(r, f2,
a = MessageAttachment(message=msg,document=f3)
a.save()
# res = myqueue(
# queuelow,
# handle_zip_file,
# r.user.email,
# title,
# f2
# )
return -1, message, f2
# Some people try to upload Concept2 logbook summaries
@@ -1564,7 +1558,7 @@ def getsmallrowdata_db(columns, ids=[], doclean=True, workstrokesonly=True):
cdata2 = savgol_filter(cdata.values,windowsize,3)
print len(cdata),len(cdata2),'mies'
data[c] = cdata
data[c] = cdata2
except KeyError:
data[c] = 0
@@ -1642,12 +1636,14 @@ def read_cols_df_sql(ids, columns, convertnewtons=True):
axx = [f.name for f in StrokeData._meta.get_fields()]
extracols = []
for c in columns:
if not c in axx:
columns.remove(c)
extracols.append(c)
columns = list(columns) + ['distance', 'spm', 'workoutid']
columns = [x for x in columns if x != 'None']
columns = list(set(columns))

View File

@@ -94,7 +94,15 @@
{% endif %}
{% endfor %}
{% endif %}
{% if promember %}
{% for key, value in extrametrics.items %}
<a class="button orange small" href="/rowers/workout/{{ id }}/flexchart/{{ xparam }}/{{ key }}/{{ yparam2 }}/{{ plottype }}">{{ value }}</a>
{% endfor %}
{% else %}
{% for key, value in extrametrics.items %}
<a class="button rosy small" href="/rowers/promembership">{{ value }} (Pro)</a>
{% endfor %}
{% endif %}
</div>
</div>
@@ -119,6 +127,15 @@
{% endif %}
{% endfor %}
{% endif %}
{% if promember %}
{% for key, value in extrametrics.items %}
<a class="button orange small" href="/rowers/workout/{{ id }}/flexchart/{{ xparam }}/{{ yparam1 }}/{{ key }}/{{ plottype }}">{{ value }}</a>
{% endfor %}
{% else %}
{% for key, value in extrametrics.items %}
<a class="button rosy small" href="/rowers/promembership">{{ value }} (Pro)</a>
{% endfor %}
{% endif %}
</div>
</div>

View File

@@ -363,12 +363,12 @@ urlpatterns = [
url(r'^register/thankyou/$', TemplateView.as_view(template_name='registerthankyou.html'), name='registerthankyou'),
url(r'^workout/(?P<id>\d+)/workflow$',views.workout_workflow_view,
name='workout_workflow_view'),
url(r'^workout/(?P<id>\d+)/flexchart/(?P<xparam>\w+.*)/(?P<yparam1>\w+.*)/(?P<yparam2>\w+.*)/(?P<plottype>\w+)/$',views.workout_flexchart3_view),
url(r'^workout/(?P<id>\d+)/flexchart/(?P<xparam>\w+.*)/(?P<yparam1>\w+.*)/(?P<yparam2>\w+.*)/(?P<plottype>\w+.*)$',views.workout_flexchart3_view),
url(r'^workout/(?P<id>\d+)/flexchart/(?P<xparam>\w+.*)/(?P<yparam1>\w+.*)/(?P<yparam2>\w+.*)$',views.workout_flexchart3_view),
url(r'^workout/(?P<id>\d+)/flexchart/(?P<xparam>\w+.*)/(?P<yparam1>[\w\ ]+.*)/(?P<yparam2>[\w\ ]+.*)/(?P<plottype>\w+)/$',views.workout_flexchart3_view),
url(r'^workout/(?P<id>\d+)/flexchart/(?P<xparam>\w+.*)/(?P<yparam1>[\w\ ]+.*)/(?P<yparam2>[\w\ ]+.*)/(?P<plottype>\w+.*)$',views.workout_flexchart3_view),
url(r'^workout/(?P<id>\d+)/flexchart/(?P<xparam>\w+.*)/(?P<yparam1>[\w\ ]+.*)/(?P<yparam2>[\w\ ]+.*)$',views.workout_flexchart3_view),
url(r'^workout/(?P<id>\d+)/flexchart$',views.workout_flexchart3_view),
url(r'^workout/compare/(?P<id1>\d+)/(?P<id2>\d+)/(?P<xparam>\w+.*)/(?P<yparam>\w+.*)/(?P<plottype>\w+.*)$',views.workout_comparison_view2),
url(r'^workout/compare/(?P<id1>\d+)/(?P<id2>\d+)/(?P<xparam>\w+.*)/(?P<yparam>\w+.*)/$',views.workout_comparison_view2),
url(r'^workout/compare/(?P<id1>\d+)/(?P<id2>\d+)/(?P<xparam>\w+.*)/(?P<yparam>[\w\ ]+.*)/(?P<plottype>[\w\ ]+.*)$',views.workout_comparison_view2),
url(r'^workout/compare/(?P<id1>\d+)/(?P<id2>\d+)/(?P<xparam>\w+.*)/(?P<yparam>[\w\ ]+.*)/$',views.workout_comparison_view2),
url(r'^test\_callback',views.rower_process_testcallback),
url(r'^workout/(?P<id>\d+)/test\_strokedata$',views.strokedataform),
]

View File

@@ -6455,7 +6455,10 @@ def instroke_view(request,id=0):
return HttpResponseRedirect(url)
rowdata = rrdata(csvfile=row.csvfilename)
instrokemetrics = rowdata.get_instroke_columns()
try:
instrokemetrics = rowdata.get_instroke_columns()
except AttributeError:
instrokemetrics = []
return render(request,
@@ -7491,7 +7494,12 @@ def workout_flexchart3_view(request,*args,**kwargs):
if yparam2 == name:
yparam2 = 'spm'
messages.info(request,'To use '+d['verbose_name']+', you have to be Pro member')
# bring back slashes
yparam1 = yparam1.replace('_slsh_','/')
yparam2 = yparam2.replace('_slsh_','/')
xparam = xparam.replace('_slsh_','/')
# create interactive plot
try:
script,div,js_resources,css_resources,workstrokesonly = interactive_flex_chart2(id,xparam=xparam,yparam1=yparam1,
@@ -7517,55 +7525,61 @@ def workout_flexchart3_view(request,*args,**kwargs):
if d['mode'] == 'erg':
axchoicespro.pop(name)
return render(request,
'flexchart3otw.html',
{'the_script':script,
'the_div':div,
'js_res': js_resources,
'css_res':css_resources,
'id':int(id),
'teams':get_my_teams(request.user),
'xparam':xparam,
'yparam1':yparam1,
'yparam2':yparam2,
'plottype':plottype,
'favoritechartnotes':favoritechartnotes,
'mayedit':mayedit,
'promember':promember,
'axchoicesbasic':axchoicesbasic,
'axchoicespro':axchoicespro,
'noylist':noylist,
'workstrokesonly': not workstrokesonly,
'favoritenr':favoritenr,
'maxfav':maxfav,
})
else:
for name,d in rowingmetrics:
if d['mode'] == 'water':
axchoicespro.pop(name)
return render(request,
'flexchart3otw.html',
{'the_script':script,
'the_div':div,
'js_res': js_resources,
'css_res':css_resources,
'teams':get_my_teams(request.user),
'id':int(id),
'xparam':xparam,
'yparam1':yparam1,
'yparam2':yparam2,
'plottype':plottype,
'axchoicesbasic':axchoicesbasic,
'axchoicespro':axchoicespro,
'favoritechartnotes':favoritechartnotes,
'noylist':noylist,
'mayedit':mayedit,
'promember':promember,
'workstrokesonly': not workstrokesonly,
'favoritenr':favoritenr,
'maxfav':maxfav,
})
rowdata = rdata(row.csvfilename)
additionalmetrics = rowdata.get_additional_metrics()
extrametrics = {m.replace('/','_slsh_'):m for m in additionalmetrics}
try:
extrametrics.pop('originalvelo')
except KeyError:
pass
try:
extrametrics.pop('cumdist')
except KeyError:
pass
try:
extrametrics.pop(' Cadence (strokes_slsh_min)')
except KeyError:
pass
try:
extrametrics.pop(' WorkPerStroke (joules)')
except KeyError:
pass
return render(request,
'flexchart3otw.html',
{'the_script':script,
'the_div':div,
'js_res': js_resources,
'css_res':css_resources,
'teams':get_my_teams(request.user),
'id':int(id),
'xparam':xparam,
'yparam1':yparam1,
'yparam2':yparam2,
'plottype':plottype,
'axchoicesbasic':axchoicesbasic,
'axchoicespro':axchoicespro,
'extrametrics':extrametrics,
'favoritechartnotes':favoritechartnotes,
'noylist':noylist,
'mayedit':mayedit,
'promember':promember,
'workstrokesonly': not workstrokesonly,
'favoritenr':favoritenr,
'maxfav':maxfav,
})
# The interactive plot with the colored Heart rate zones