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