activity chart without duplicates
This commit is contained in:
@@ -237,8 +237,6 @@ def interactive_boxchart(datadf,fieldname,extratitle=''):
|
|||||||
|
|
||||||
|
|
||||||
def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
||||||
if len(workouts) == 0:
|
|
||||||
return "",""
|
|
||||||
|
|
||||||
dates = []
|
dates = []
|
||||||
dates_sorting = []
|
dates_sorting = []
|
||||||
@@ -316,7 +314,10 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'):
|
|||||||
label = CatAttr(columns=['date'], sort=False),
|
label = CatAttr(columns=['date'], sort=False),
|
||||||
xlabel='Date',
|
xlabel='Date',
|
||||||
ylabel='Time',
|
ylabel='Time',
|
||||||
title='Activity',
|
title='Activity {d1} to {d2}'.format(
|
||||||
|
d1 = startdate.strftime("%Y-%m-%d"),
|
||||||
|
d2 = enddate.strftime("%Y-%m-%d"),
|
||||||
|
),
|
||||||
stack=stack,
|
stack=stack,
|
||||||
plot_width=350,
|
plot_width=350,
|
||||||
plot_height=250,
|
plot_height=250,
|
||||||
|
|||||||
@@ -6754,6 +6754,7 @@ def workouts_view(request,message='',successmessage='',
|
|||||||
enddate = startdate
|
enddate = startdate
|
||||||
startdate = s
|
startdate = s
|
||||||
|
|
||||||
|
|
||||||
startdatestring = startdate.strftime('%Y-%m-%d')
|
startdatestring = startdate.strftime('%Y-%m-%d')
|
||||||
enddatestring = enddate.strftime('%Y-%m-%d')
|
enddatestring = enddate.strftime('%Y-%m-%d')
|
||||||
|
|
||||||
@@ -6769,6 +6770,10 @@ def workouts_view(request,message='',successmessage='',
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
activity_enddate = enddate
|
activity_enddate = enddate
|
||||||
|
|
||||||
|
g_startdate = activity_startdate
|
||||||
|
g_enddate = activity_enddate
|
||||||
|
|
||||||
|
|
||||||
if teamid:
|
if teamid:
|
||||||
try:
|
try:
|
||||||
theteam = Team.objects.get(id=teamid)
|
theteam = Team.objects.get(id=teamid)
|
||||||
@@ -6785,6 +6790,7 @@ def workouts_view(request,message='',successmessage='',
|
|||||||
team=theteam,
|
team=theteam,
|
||||||
startdatetime__gte=activity_startdate,
|
startdatetime__gte=activity_startdate,
|
||||||
startdatetime__lte=activity_enddate,
|
startdatetime__lte=activity_enddate,
|
||||||
|
duplicate=False,
|
||||||
privacy='visible').order_by("-date", "-starttime")
|
privacy='visible').order_by("-date", "-starttime")
|
||||||
elif theteam.viewing == 'coachonly':
|
elif theteam.viewing == 'coachonly':
|
||||||
workouts = Workout.objects.filter(
|
workouts = Workout.objects.filter(
|
||||||
@@ -6796,6 +6802,7 @@ def workouts_view(request,message='',successmessage='',
|
|||||||
team=theteam,user=r,
|
team=theteam,user=r,
|
||||||
startdatetime__gte=activity_startdate,
|
startdatetime__gte=activity_startdate,
|
||||||
enddatetime__lte=activity_enddate,
|
enddatetime__lte=activity_enddate,
|
||||||
|
duplicate=False,
|
||||||
privacy='visible').order_by("-startdatetime")
|
privacy='visible').order_by("-startdatetime")
|
||||||
|
|
||||||
|
|
||||||
@@ -6811,6 +6818,7 @@ def workouts_view(request,message='',successmessage='',
|
|||||||
user=r,
|
user=r,
|
||||||
startdatetime__gte=activity_startdate,
|
startdatetime__gte=activity_startdate,
|
||||||
startdatetime__lte=activity_enddate,
|
startdatetime__lte=activity_enddate,
|
||||||
|
duplicate=False,
|
||||||
privacy='visible').order_by("-startdatetime")
|
privacy='visible').order_by("-startdatetime")
|
||||||
else:
|
else:
|
||||||
theteam = None
|
theteam = None
|
||||||
@@ -6820,9 +6828,18 @@ def workouts_view(request,message='',successmessage='',
|
|||||||
startdatetime__lte=enddate).order_by("-date", "-starttime")
|
startdatetime__lte=enddate).order_by("-date", "-starttime")
|
||||||
g_workouts = Workout.objects.filter(
|
g_workouts = Workout.objects.filter(
|
||||||
user=r,
|
user=r,
|
||||||
|
duplicate=False,
|
||||||
startdatetime__gte=activity_startdate,
|
startdatetime__gte=activity_startdate,
|
||||||
startdatetime__lte=activity_enddate).order_by("-startdatetime")
|
startdatetime__lte=activity_enddate).order_by("-startdatetime")
|
||||||
|
|
||||||
|
|
||||||
|
if len(g_workouts) == 0:
|
||||||
|
g_workouts = Workout.objects.filter(
|
||||||
|
user=r,
|
||||||
|
startdatetime__gte=timezone.now()-timedelta(days=15)).order_by("-startdatetime")
|
||||||
|
g_enddate = timezone.now()
|
||||||
|
g_startdate = (timezone.now()-timedelta(days=15))
|
||||||
|
|
||||||
if rankingonly:
|
if rankingonly:
|
||||||
workouts = workouts.exclude(rankingpiece=False)
|
workouts = workouts.exclude(rankingpiece=False)
|
||||||
|
|
||||||
@@ -6860,9 +6877,10 @@ def workouts_view(request,message='',successmessage='',
|
|||||||
else:
|
else:
|
||||||
stack='type'
|
stack='type'
|
||||||
|
|
||||||
|
|
||||||
script,div = interactive_activitychart(g_workouts,
|
script,div = interactive_activitychart(g_workouts,
|
||||||
activity_startdate,
|
g_startdate,
|
||||||
activity_enddate,
|
g_enddate,
|
||||||
stack=stack)
|
stack=stack)
|
||||||
|
|
||||||
messages.info(request,successmessage)
|
messages.info(request,successmessage)
|
||||||
|
|||||||
Reference in New Issue
Block a user