Merge branch 'release/v12.36'
This commit is contained in:
@@ -26,7 +26,7 @@ from bokeh.models import CustomJS,Slider, TextInput,BoxAnnotation
|
|||||||
from bokeh.resources import CDN,INLINE
|
from bokeh.resources import CDN,INLINE
|
||||||
from bokeh.embed import components
|
from bokeh.embed import components
|
||||||
from bokeh.layouts import layout,widgetbox
|
from bokeh.layouts import layout,widgetbox
|
||||||
from bokeh.palettes import Category20c
|
from bokeh.palettes import Category20c,Category10
|
||||||
from bokeh.layouts import row as layoutrow
|
from bokeh.layouts import row as layoutrow
|
||||||
from bokeh.layouts import column as layoutcolumn
|
from bokeh.layouts import column as layoutcolumn
|
||||||
from bokeh.models import LinearAxis,LogAxis,Range1d,DatetimeTickFormatter,HoverTool
|
from bokeh.models import LinearAxis,LogAxis,Range1d,DatetimeTickFormatter,HoverTool
|
||||||
@@ -278,7 +278,7 @@ def interactive_workouttype_piechart(workouts):
|
|||||||
data = pd.Series(datadict).reset_index(name='value').rename(columns={'index':'type'})
|
data = pd.Series(datadict).reset_index(name='value').rename(columns={'index':'type'})
|
||||||
data['angle'] = data['value']/data['value'].sum() * 2*pi
|
data['angle'] = data['value']/data['value'].sum() * 2*pi
|
||||||
if len(datadict)>2:
|
if len(datadict)>2:
|
||||||
data['color'] = Category20c[len(datadict)]
|
data['color'] = Category10[len(datadict)]
|
||||||
elif len(datadict)==2:
|
elif len(datadict)==2:
|
||||||
data['color'] = ['orange','lightblue']
|
data['color'] = ['orange','lightblue']
|
||||||
else:
|
else:
|
||||||
@@ -401,7 +401,7 @@ def interactive_planchart(data,startdate,enddate):
|
|||||||
|
|
||||||
return script,div
|
return script,div
|
||||||
|
|
||||||
def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
def interactive_activitychart(workouts,startdate,enddate,stack='type',toolbar_location=None):
|
||||||
|
|
||||||
dates = []
|
dates = []
|
||||||
dates_sorting = []
|
dates_sorting = []
|
||||||
@@ -414,6 +414,13 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
|||||||
seen = ['seen']
|
seen = ['seen']
|
||||||
idseen = []
|
idseen = []
|
||||||
|
|
||||||
|
startdate = datetime.datetime(year=startdate.year,month=startdate.month,day=startdate.day)
|
||||||
|
enddate = datetime.datetime(year=enddate.year,month=enddate.month,day=enddate.day)
|
||||||
|
|
||||||
|
duration = enddate-startdate
|
||||||
|
|
||||||
|
totaldays = duration.total_seconds()/(24*3600)
|
||||||
|
|
||||||
|
|
||||||
for w in workouts:
|
for w in workouts:
|
||||||
aantal=1
|
aantal=1
|
||||||
@@ -432,9 +439,15 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
|||||||
for w in workouts:
|
for w in workouts:
|
||||||
dd = w.date.strftime('%m/%d')
|
dd = w.date.strftime('%m/%d')
|
||||||
dd2 = w.date.strftime('%Y/%m/%d')
|
dd2 = w.date.strftime('%Y/%m/%d')
|
||||||
|
dd3 = w.date.strftime('%Y/%m')
|
||||||
du = w.duration.hour*60+w.duration.minute
|
du = w.duration.hour*60+w.duration.minute
|
||||||
|
|
||||||
|
if totaldays<30:
|
||||||
dates.append(dd)
|
dates.append(dd)
|
||||||
dates_sorting.append(dd2)
|
dates_sorting.append(dd2)
|
||||||
|
else:
|
||||||
|
dates.append(dd3)
|
||||||
|
dates_sorting.append(dd3)
|
||||||
durations.append(du)
|
durations.append(du)
|
||||||
links.append(
|
links.append(
|
||||||
"{siteurl}/rowers/workout/{code}/".format(
|
"{siteurl}/rowers/workout/{code}/".format(
|
||||||
@@ -451,21 +464,25 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
d = utc.localize(startdate)
|
d = utc.localize(startdate)
|
||||||
except ValueError:
|
except (ValueError,AttributeError):
|
||||||
d = startdate
|
d = startdate
|
||||||
|
|
||||||
try:
|
try:
|
||||||
enddate = utc.localize(enddate)
|
enddate = utc.localize(enddate)
|
||||||
except ValueError:
|
except (ValueError,AttributeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# add dates with no activity
|
# add dates with no activity
|
||||||
while d<=enddate:
|
while d<=enddate:
|
||||||
dd = d.strftime('%d')
|
dd = d.strftime('%d')
|
||||||
|
|
||||||
|
|
||||||
|
if totaldays<30:
|
||||||
dates.append(d.strftime('%m/%d'))
|
dates.append(d.strftime('%m/%d'))
|
||||||
|
|
||||||
|
|
||||||
dates_sorting.append(d.strftime('%Y/%m/%d'))
|
dates_sorting.append(d.strftime('%Y/%m/%d'))
|
||||||
|
else:
|
||||||
|
dates.append(d.strftime('%Y/%m'))
|
||||||
|
dates_sorting.append(d.strftime('%Y/%m'))
|
||||||
durations.append(0)
|
durations.append(0)
|
||||||
links.append('')
|
links.append('')
|
||||||
types.append('rower')
|
types.append('rower')
|
||||||
@@ -489,6 +506,9 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
|||||||
'link':links,
|
'link':links,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
types_ind = list(set(types))
|
||||||
|
|
||||||
|
|
||||||
df = pd.DataFrame(thedict)
|
df = pd.DataFrame(thedict)
|
||||||
|
|
||||||
source = ColumnDataSource(df)
|
source = ColumnDataSource(df)
|
||||||
@@ -521,7 +541,7 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
|||||||
|
|
||||||
p.plot_width=550
|
p.plot_width=550
|
||||||
p.plot_height=350
|
p.plot_height=350
|
||||||
p.toolbar_location = 'above'
|
p.toolbar_location = toolbar_location
|
||||||
p.sizing_mode = 'scale_width'
|
p.sizing_mode = 'scale_width'
|
||||||
url = "http://rowsandall.com/rowers/workout/@duration/"
|
url = "http://rowsandall.com/rowers/workout/@duration/"
|
||||||
taptool = p.select(type=TapTool)
|
taptool = p.select(type=TapTool)
|
||||||
|
|||||||
@@ -25,9 +25,12 @@
|
|||||||
{{ tscript|safe}}
|
{{ tscript|safe}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="activities_script">
|
||||||
|
</div>
|
||||||
|
|
||||||
<ul class="main-content">
|
<ul class="main-content">
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
<h1>History for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
<h1>History for {{ rower.user.first_name }} {{ rower.user.last_name }} from {{ startdate }} to {{ enddate }}</h1>
|
||||||
</li>
|
</li>
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
<a href="/rowers/history/?enddate={{ today|date:"Y-m-d" }}&startdate={{ lastseven|date:"Y-m-d" }}&workouttype={{ workouttype }}">Past 7 days</a>
|
<a href="/rowers/history/?enddate={{ today|date:"Y-m-d" }}&startdate={{ lastseven|date:"Y-m-d" }}&workouttype={{ workouttype }}">Past 7 days</a>
|
||||||
@@ -37,6 +40,8 @@
|
|||||||
<a href="/rowers/history/?enddate={{ today|date:"Y-m-d" }}&startdate={{ last28|date:"Y-m-d" }}&workouttype={{ workouttype }}">Past 28 days</a>
|
<a href="/rowers/history/?enddate={{ today|date:"Y-m-d" }}&startdate={{ last28|date:"Y-m-d" }}&workouttype={{ workouttype }}">Past 28 days</a>
|
||||||
|
|
||||||
<a href="/rowers/history/?enddate={{ today|date:"Y-m-d" }}&startdate={{ firstmay|date:"Y-m-d" }}&workouttype={{ workouttype }}">Current Concept2 Season</a>
|
<a href="/rowers/history/?enddate={{ today|date:"Y-m-d" }}&startdate={{ firstmay|date:"Y-m-d" }}&workouttype={{ workouttype }}">Current Concept2 Season</a>
|
||||||
|
|
||||||
|
<a href="/rowers/history/?enddate={{ today|date:"Y-m-d" }}&startdate={{ lastyear|date:"Y-m-d" }}&workouttype={{ workouttype }}">Past 12 months</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
<p>
|
<p>
|
||||||
@@ -79,6 +84,10 @@
|
|||||||
</table>
|
</table>
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="grid_2">
|
||||||
|
<div id="id_activities">
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
{{ tdiv|safe }}
|
{{ tdiv|safe }}
|
||||||
</li>
|
</li>
|
||||||
@@ -134,18 +143,23 @@
|
|||||||
<script>
|
<script>
|
||||||
$(function($) {
|
$(function($) {
|
||||||
console.log('loading script for chart');
|
console.log('loading script for chart');
|
||||||
|
var ed = '{{ senddate|date:"Y-m-d" }}'
|
||||||
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/history/user/{{ rower.user.id }}/data/?startdate={{ startdate|date:"Y-m-d" }}&{{ enddate|date:"Y-m-d" }}&workouttype={{ workouttype }}', function(json) {
|
console.log('End',ed);
|
||||||
|
console.log(window.location.protocol + '//'+window.location.host + '/rowers/history/user/{{ rower.user.id }}/data/?startdate={{ sstartdate|date:"Y-m-d" }}&enddate={{ senddate|date:"Y-m-d" }}&workouttype={{ workouttype }}')
|
||||||
|
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/history/user/{{ rower.user.id }}/data/?startdate={{ sstartdate|date:"Y-m-d" }}&enddate={{ senddate|date:"Y-m-d" }}&workouttype={{ workouttype }}', function(json) {
|
||||||
|
|
||||||
var script = json.script;
|
var script = json.script;
|
||||||
var div = json.div;
|
var div = json.div;
|
||||||
var totalsdict = json.totalsdict
|
var totalsdict = json.totalsdict
|
||||||
var listofdicts = json.listofdicts
|
var listofdicts = json.listofdicts
|
||||||
|
var activities_script = json.activities_script
|
||||||
|
var activities_chart = json.activities_chart
|
||||||
$("#id_sitready").remove();
|
$("#id_sitready").remove();
|
||||||
$("#id_chart").append(div);
|
$("#id_chart").append(div);
|
||||||
console.log(div);
|
|
||||||
// $("#id_script").append("<s"+"cript>"+script+"</s"+"cript>");
|
// $("#id_script").append("<s"+"cript>"+script+"</s"+"cript>");
|
||||||
$("#id_script").append(script);
|
$("#id_script").append(script);
|
||||||
|
$("#id_activities").append(activities_chart)
|
||||||
|
$("#activities_script").append(activities_script)
|
||||||
$("#total_hr").append(totalsdict.hrmean);
|
$("#total_hr").append(totalsdict.hrmean);
|
||||||
$("#total_maxhr").append(totalsdict.hrmax);
|
$("#total_maxhr").append(totalsdict.hrmax);
|
||||||
$("#total_power").append(totalsdict.powermean);
|
$("#total_power").append(totalsdict.powermean);
|
||||||
|
|||||||
@@ -4662,6 +4662,8 @@ def history_view(request,userid=0):
|
|||||||
|
|
||||||
if request.GET.get('startdate'):
|
if request.GET.get('startdate'):
|
||||||
startdate,enddate = get_dates_timeperiod(request)
|
startdate,enddate = get_dates_timeperiod(request)
|
||||||
|
sstartdate = startdate
|
||||||
|
senddate = enddate
|
||||||
activity_startdate = datetime.datetime(
|
activity_startdate = datetime.datetime(
|
||||||
startdate.year,startdate.month,startdate.day
|
startdate.year,startdate.month,startdate.day
|
||||||
).replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
).replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
||||||
@@ -4673,6 +4675,12 @@ def history_view(request,userid=0):
|
|||||||
activity_enddate = activity_enddate.replace(hour=23,minute=59,second=59).astimezone(usertimezone)
|
activity_enddate = activity_enddate.replace(hour=23,minute=59,second=59).astimezone(usertimezone)
|
||||||
activity_startdate = activity_enddate-datetime.timedelta(days=15)
|
activity_startdate = activity_enddate-datetime.timedelta(days=15)
|
||||||
activity_startdate = activity_startdate.replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
activity_startdate = activity_startdate.replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
||||||
|
sstartdate = datetime.date(year=activity_startdate.year,month=activity_startdate.month,
|
||||||
|
day=activity_startdate.day)
|
||||||
|
senddate = datetime.date(year=activity_enddate.year,month=activity_enddate.month,
|
||||||
|
day=activity_enddate.day)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typeselect = 'All'
|
typeselect = 'All'
|
||||||
if request.GET.get('workouttype'):
|
if request.GET.get('workouttype'):
|
||||||
@@ -4685,6 +4693,8 @@ def history_view(request,userid=0):
|
|||||||
'enddate':activity_enddate,
|
'enddate':activity_enddate,
|
||||||
'workouttype':typeselect})
|
'workouttype':typeselect})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
g_workouts = Workout.objects.filter(
|
g_workouts = Workout.objects.filter(
|
||||||
user=r,
|
user=r,
|
||||||
startdatetime__gte=activity_startdate,
|
startdatetime__gte=activity_startdate,
|
||||||
@@ -4693,6 +4703,7 @@ def history_view(request,userid=0):
|
|||||||
privacy='visible'
|
privacy='visible'
|
||||||
).order_by("-startdatetime")
|
).order_by("-startdatetime")
|
||||||
|
|
||||||
|
|
||||||
ids = [w.id for w in g_workouts]
|
ids = [w.id for w in g_workouts]
|
||||||
|
|
||||||
columns = ['hr','power','time']
|
columns = ['hr','power','time']
|
||||||
@@ -4763,12 +4774,17 @@ def history_view(request,userid=0):
|
|||||||
lastseven = timezone.now()-datetime.timedelta(days=7)
|
lastseven = timezone.now()-datetime.timedelta(days=7)
|
||||||
lastfourteen = timezone.now()-datetime.timedelta(days=14)
|
lastfourteen = timezone.now()-datetime.timedelta(days=14)
|
||||||
last28 = timezone.now()-datetime.timedelta(days=28)
|
last28 = timezone.now()-datetime.timedelta(days=28)
|
||||||
|
|
||||||
today = timezone.now()
|
today = timezone.now()
|
||||||
|
|
||||||
|
lastyear = datetime.datetime(year=today.year-1,month=today.month,day=today.day)
|
||||||
|
|
||||||
firstmay = datetime.datetime(year=today.year,month=5,day=1).astimezone(usertimezone)
|
firstmay = datetime.datetime(year=today.year,month=5,day=1).astimezone(usertimezone)
|
||||||
if firstmay>today:
|
if firstmay>today:
|
||||||
firstmay = datetime.datetime(year=today.year-1,month=5,day=1)
|
firstmay = datetime.datetime(year=today.year-1,month=5,day=1)
|
||||||
|
|
||||||
|
print(sstartdate,senddate,'history')
|
||||||
|
|
||||||
return render(request,'history.html',
|
return render(request,'history.html',
|
||||||
{
|
{
|
||||||
'tscript':tscript,
|
'tscript':tscript,
|
||||||
@@ -4786,9 +4802,12 @@ def history_view(request,userid=0):
|
|||||||
'lastseven':lastseven,
|
'lastseven':lastseven,
|
||||||
'lastfourteen':lastfourteen,
|
'lastfourteen':lastfourteen,
|
||||||
'last28':last28,
|
'last28':last28,
|
||||||
|
'lastyear':lastyear,
|
||||||
'today':today,
|
'today':today,
|
||||||
'workouttype':typeselect,
|
'workouttype':typeselect,
|
||||||
'firstmay':firstmay,
|
'firstmay':firstmay,
|
||||||
|
'sstartdate':sstartdate,
|
||||||
|
'senddate':senddate,
|
||||||
})
|
})
|
||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
@@ -4797,8 +4816,10 @@ def history_view_data(request,userid=0):
|
|||||||
|
|
||||||
usertimezone = pytz.timezone(r.defaulttimezone)
|
usertimezone = pytz.timezone(r.defaulttimezone)
|
||||||
|
|
||||||
|
print(request.GET)
|
||||||
if request.GET.get('startdate'):
|
if request.GET.get('startdate'):
|
||||||
startdate,enddate = get_dates_timeperiod(request)
|
startdate = datetime.datetime.strptime(request.GET.get('startdate'),"%Y-%m-%d")
|
||||||
|
enddate = datetime.datetime.strptime(request.GET.get('enddate'),"%Y-%m-%d")
|
||||||
activity_startdate = datetime.datetime(
|
activity_startdate = datetime.datetime(
|
||||||
startdate.year,startdate.month,startdate.day
|
startdate.year,startdate.month,startdate.day
|
||||||
).replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
).replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
||||||
@@ -4811,6 +4832,8 @@ def history_view_data(request,userid=0):
|
|||||||
activity_startdate = activity_enddate-datetime.timedelta(days=15)
|
activity_startdate = activity_enddate-datetime.timedelta(days=15)
|
||||||
activity_startdate = activity_startdate.replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
activity_startdate = activity_startdate.replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typeselect = 'All'
|
typeselect = 'All'
|
||||||
if request.GET.get('workouttype'):
|
if request.GET.get('workouttype'):
|
||||||
typeselect = request.GET.get('workouttype')
|
typeselect = request.GET.get('workouttype')
|
||||||
@@ -4818,6 +4841,7 @@ def history_view_data(request,userid=0):
|
|||||||
if typeselect not in mytypes.checktypes:
|
if typeselect not in mytypes.checktypes:
|
||||||
typeselect = 'All'
|
typeselect = 'All'
|
||||||
|
|
||||||
|
|
||||||
g_workouts = Workout.objects.filter(
|
g_workouts = Workout.objects.filter(
|
||||||
user=r,
|
user=r,
|
||||||
startdatetime__gte=activity_startdate,
|
startdatetime__gte=activity_startdate,
|
||||||
@@ -4902,6 +4926,8 @@ def history_view_data(request,userid=0):
|
|||||||
|
|
||||||
totalsdict['nrworkouts'] = g_workouts.count()
|
totalsdict['nrworkouts'] = g_workouts.count()
|
||||||
|
|
||||||
|
# activity chart
|
||||||
|
activity_script, activity_div = interactive_activitychart(g_workouts,startdate,enddate)
|
||||||
|
|
||||||
# interactive hr pie chart
|
# interactive hr pie chart
|
||||||
if typeselect == 'All':
|
if typeselect == 'All':
|
||||||
@@ -4928,4 +4954,6 @@ def history_view_data(request,userid=0):
|
|||||||
'div':totaldiv,
|
'div':totaldiv,
|
||||||
'totalsdict':totalsdict,
|
'totalsdict':totalsdict,
|
||||||
'listofdicts':listofdicts,
|
'listofdicts':listofdicts,
|
||||||
|
'activities_script':activity_script,
|
||||||
|
'activities_chart':activity_div,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user