minimum viable version of improved stats
This commit is contained in:
@@ -968,6 +968,12 @@ def read_cols_df_sql(ids,columns):
|
||||
connection = engine.raw_connection()
|
||||
df = pd.read_sql_query(query,engine)
|
||||
df = df.fillna(value=0)
|
||||
try:
|
||||
df['peakforce'] = df['peakforce']*lbstoN
|
||||
df['averageforce'] = df['averageforce']*lbstoN
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
engine.dispose()
|
||||
return df
|
||||
|
||||
@@ -980,6 +986,12 @@ def read_df_sql(id):
|
||||
|
||||
engine.dispose()
|
||||
df = df.fillna(value=0)
|
||||
try:
|
||||
df['peakforce'] = df['peakforce']*lbstoN
|
||||
df['averageforce'] = df['averageforce']*lbstoN
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return df
|
||||
|
||||
# Get the necessary data from the strokedata table in the DB.
|
||||
|
||||
@@ -4,7 +4,7 @@ from rowingdata import main as rmain
|
||||
from rowingdata import cumcpdata,histodata
|
||||
|
||||
from rowingdata import rowingdata as rrdata
|
||||
|
||||
from math import pi
|
||||
from django.utils import timezone
|
||||
|
||||
from bokeh.palettes import Dark2_8 as palette
|
||||
@@ -88,15 +88,27 @@ from rowers.dataprep import nicepaceformat,niceformat
|
||||
from rowers.dataprep import timedeltaconv
|
||||
|
||||
def interactive_boxchart(datadf,fieldname):
|
||||
|
||||
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,resize'
|
||||
plot = BoxPlot(datadf, values=fieldname, label='date',
|
||||
legend=False,
|
||||
title=axlabels[fieldname],
|
||||
outliers=False)
|
||||
outliers=False,
|
||||
tools=TOOLS,
|
||||
x_mapper_type='datetime')
|
||||
|
||||
yrange1 = Range1d(start=yaxminima[fieldname],end=yaxmaxima[fieldname])
|
||||
plot.y_range = yrange1
|
||||
|
||||
plot.xaxis.axis_label = 'Date'
|
||||
plot.yaxis.axis_label = axlabels[fieldname]
|
||||
|
||||
|
||||
plot.xaxis.formatter = DatetimeTickFormatter(
|
||||
days=["%d %B %Y"],
|
||||
months=["%d %B %Y"],
|
||||
years=["%d %B %Y"],
|
||||
)
|
||||
plot.xaxis.major_label_orientation = pi/4
|
||||
|
||||
script, div = components(plot)
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
between {{ startdate|date }} and {{ enddate|date }}</p>
|
||||
|
||||
<p>Direct link for other Pro users:
|
||||
<a href="/rowers/{{ id }}/cumstats/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}">https://rowsandall.com/rowers/{{ id }}/cumstats/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}</a>
|
||||
<a href="/rowers/{{ id }}/cumstats/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}/p/{{ plotfield }}">https://rowsandall.com/rowers/{{ id }}/cumstats/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}/p/{{ plotfield }}</a>
|
||||
</p>
|
||||
|
||||
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
|
||||
@@ -95,7 +95,13 @@
|
||||
<div class="grid_4 alpha">
|
||||
{% if stats %}
|
||||
{% for key, value in stats.items %}
|
||||
<h2>{{ value.verbosename }}</h2>
|
||||
<h2>{{ value.verbosename }}</h2>
|
||||
<div class="grid_1">
|
||||
<p>
|
||||
<a class="button blue small" href="/rowers/{{ id }}/cumstats/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}/p/{{ key }}">Plot</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<table width="100%" class="listtable">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -141,6 +141,8 @@ urlpatterns = [
|
||||
url(r'^histo/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.histo),
|
||||
url(r'^histo/(?P<deltadays>\d+)$',views.histo),
|
||||
url(r'^histo/$',views.histo),
|
||||
url(r'^cumstats/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)/p/(?P<plotfield>\w+.*)$',views.cumstats),
|
||||
url(r'^(?P<theuser>\d+)/cumstats/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)/p/(?P<plotfield>\w+.*)$',views.cumstats),
|
||||
url(r'^(?P<theuser>\d+)/cumstats/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.cumstats),
|
||||
url(r'^(?P<theuser>\d+)/cumstats/(?P<deltadays>\d+)$',views.cumstats),
|
||||
url(r'^cumstats/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.cumstats),
|
||||
|
||||
@@ -3839,6 +3839,7 @@ def cumstats(request,theuser=0,
|
||||
deltadays=-1,
|
||||
startdatestring="",
|
||||
enddatestring="",
|
||||
plotfield='spm',
|
||||
options={
|
||||
'includereststrokes':False,
|
||||
'workouttypes':['rower','dynamic','slides']
|
||||
@@ -4010,7 +4011,8 @@ def cumstats(request,theuser=0,
|
||||
# interactive box plot
|
||||
datadf['workoutid'].replace(datemapping,inplace=True)
|
||||
datadf.rename(columns={"workoutid":"date"},inplace=True)
|
||||
script,div = interactive_boxchart(datadf,'wash')
|
||||
datadf = datadf.sort_values(['date'])
|
||||
script,div = interactive_boxchart(datadf,plotfield)
|
||||
|
||||
# set options form correctly
|
||||
initial = {}
|
||||
@@ -4041,6 +4043,7 @@ def cumstats(request,theuser=0,
|
||||
'cordict':cordict,
|
||||
'plotscript':script,
|
||||
'plotdiv':div,
|
||||
'plotfield':plotfield,
|
||||
})
|
||||
|
||||
request.session['options'] = options
|
||||
|
||||
Reference in New Issue
Block a user