Merge branch 'release/v12.34'
This commit is contained in:
@@ -174,32 +174,39 @@ from rowers.dataprep import timedeltaconv
|
||||
|
||||
from math import pi
|
||||
|
||||
def interactive_hr_piechart(df,rower,title):
|
||||
def interactive_hr_piechart(df,rower,title,totalseconds=0):
|
||||
if df.empty:
|
||||
return "","Not enough data to make a chart"
|
||||
|
||||
|
||||
|
||||
df.sort_values(by='hr',inplace=True)
|
||||
df['timehr'] = df['deltat']*df['hr']
|
||||
|
||||
sumtimehr = df['deltat'].sum()
|
||||
|
||||
if totalseconds == 0:
|
||||
totalseconds = sumtimehr
|
||||
|
||||
|
||||
|
||||
qry = 'hr < {ut2}'.format(ut2=rower.ut2)
|
||||
frac_lut2 = df.query(qry)['deltat'].sum()
|
||||
frac_lut2 = totalseconds*df.query(qry)['deltat'].sum()/sumtimehr
|
||||
|
||||
qry = '{ut2} <= hr < {ut1}'.format(ut1=rower.ut1,ut2=rower.ut2)
|
||||
frac_ut2 = df.query(qry)['deltat'].sum()
|
||||
frac_ut2 = totalseconds*df.query(qry)['deltat'].sum()/sumtimehr
|
||||
|
||||
qry = '{ut2} <= hr < {at}'.format(ut2=rower.ut2,at=rower.at)
|
||||
frac_ut1 = df.query(qry)['deltat'].sum()
|
||||
qry = '{ut1} <= hr < {at}'.format(ut1=rower.ut1,at=rower.at)
|
||||
frac_ut1 = totalseconds*df.query(qry)['deltat'].sum()/sumtimehr
|
||||
|
||||
qry = '{at} <= hr < {tr}'.format(at=rower.at,tr=rower.tr)
|
||||
frac_at = df.query(qry)['deltat'].sum()
|
||||
frac_at = totalseconds*df.query(qry)['deltat'].sum()/sumtimehr
|
||||
|
||||
qry = '{tr} <= hr < {an}'.format(tr=rower.tr,an=rower.an)
|
||||
frac_tr = df.query(qry)['deltat'].sum()
|
||||
frac_tr = totalseconds*df.query(qry)['deltat'].sum()/sumtimehr
|
||||
|
||||
qry = 'hr >= {an}'.format(an=rower.an)
|
||||
frac_an = df.query(qry)['deltat'].sum()
|
||||
frac_an = totalseconds*df.query(qry)['deltat'].sum()/sumtimehr
|
||||
|
||||
datadict = {
|
||||
'<ut2':frac_lut2,
|
||||
@@ -210,12 +217,18 @@ def interactive_hr_piechart(df,rower,title):
|
||||
'an': frac_an,
|
||||
}
|
||||
|
||||
|
||||
|
||||
colors = ['gray','yellow','lime','blue','purple','red']
|
||||
|
||||
|
||||
|
||||
data = pd.Series(datadict).reset_index(name='value').rename(columns={'index':'zone'})
|
||||
data['angle'] = data['value']/data['value'].sum() * 2*pi
|
||||
data['color'] = colors
|
||||
data['totaltime'] = pd.Series([pretty_timedelta(v/1000.) for v in data['value']])
|
||||
data['totaltime'] = pd.Series([pretty_timedelta(v) for v in data['value']])
|
||||
|
||||
|
||||
|
||||
size=350
|
||||
TOOLS = 'save,hover'
|
||||
|
||||
@@ -4700,7 +4700,7 @@ def history_view(request,userid=0):
|
||||
tscript,tdiv = interactive_workouttype_piechart(g_workouts)
|
||||
|
||||
totalmeters,totalhours, totalminutes, totalseconds = get_totals(g_workouts)
|
||||
|
||||
|
||||
|
||||
# meters, duration per workout type
|
||||
wtypes = list(set([w.workouttype for w in g_workouts]))
|
||||
@@ -4839,10 +4839,7 @@ def history_view_data(request,userid=0):
|
||||
ignoreadvanced=True)
|
||||
|
||||
totalmeters,totalhours, totalminutes,totalseconds = get_totals(g_workouts)
|
||||
totalminutes = "{totalminutes:02d}".format(totalminutes=totalminutes)
|
||||
|
||||
|
||||
|
||||
|
||||
# meters, duration per workout type
|
||||
wtypes = list(set([w.workouttype for w in g_workouts]))
|
||||
|
||||
@@ -4908,9 +4905,13 @@ def history_view_data(request,userid=0):
|
||||
|
||||
# interactive hr pie chart
|
||||
if typeselect == 'All':
|
||||
totalscript,totaldiv = interactive_hr_piechart(df,r,'All Workouts')
|
||||
totalseconds = 3600*totalhours+60*totalminutes+totalseconds
|
||||
totalscript,totaldiv = interactive_hr_piechart(df,r,'All Workouts',
|
||||
totalseconds=totalseconds)
|
||||
else:
|
||||
a_workouts = g_workouts.filter(workouttype=typeselect)
|
||||
hours,minutes,seconds = get_totals(a_workouts)
|
||||
totalseconds = 3600*hours+60*minutes+seconds
|
||||
ddf = getsmallrowdata_db(columns,ids=[w.id for w in a_workouts])
|
||||
try:
|
||||
ddf['deltat'] = ddf['time'].diff()
|
||||
@@ -4918,7 +4919,9 @@ def history_view_data(request,userid=0):
|
||||
pass
|
||||
ddf = dataprep.clean_df_stats(ddf,workstrokesonly=True,
|
||||
ignoreadvanced=True)
|
||||
totalscript, totaldiv = interactive_hr_piechart(ddf,r,mytypes.workouttypes_ordered[typeselect])
|
||||
totalscript, totaldiv = interactive_hr_piechart(
|
||||
ddf,r,mytypes.workouttypes_ordered[typeselect],
|
||||
totalseconds=totalseconds)
|
||||
|
||||
return JSONResponse({
|
||||
'script':totalscript,
|
||||
|
||||
Reference in New Issue
Block a user