adding cpoverlay (world class)
This commit is contained in:
@@ -39,6 +39,7 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
||||
r = getrequestrower(request, userid=userid)
|
||||
user = r.user
|
||||
userid = user.id
|
||||
worldclass = False
|
||||
|
||||
firstworkout = None
|
||||
if id:
|
||||
@@ -71,6 +72,10 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
||||
modalities = [m[0] for m in mytypes.workouttypes_ordered.items()]
|
||||
modality = 'all'
|
||||
|
||||
try:
|
||||
worldclass = options['cpoverlay']
|
||||
except KeyError:
|
||||
worldclass = False
|
||||
|
||||
|
||||
try:
|
||||
@@ -132,6 +137,12 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
||||
|
||||
options['modalities'] = modalities
|
||||
options['waterboattype'] = waterboattype
|
||||
try:
|
||||
worldclass = options['cpoverlay']
|
||||
except KeyError:
|
||||
worldclass = False
|
||||
options['cpoverlay'] = worldclass
|
||||
|
||||
|
||||
chartform = AnalysisChoiceForm(request.POST)
|
||||
if chartform.is_valid():
|
||||
@@ -240,6 +251,10 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
||||
})
|
||||
|
||||
|
||||
if r.birthdate:
|
||||
age = calculate_age(r.birthdate)
|
||||
else:
|
||||
age = 0
|
||||
|
||||
startdatestring = startdate.strftime('%Y-%m-%d')
|
||||
enddatestring = enddate.strftime('%Y-%m-%d')
|
||||
@@ -272,6 +287,10 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0,id=''):
|
||||
'chartform':chartform,
|
||||
'searchform':searchform,
|
||||
'optionsform':optionsform,
|
||||
'worldclass':worldclass,
|
||||
'age':age,
|
||||
'sex':r.sex,
|
||||
'weightcategory':r.weightcategory,
|
||||
'teams':get_my_teams(request.user),
|
||||
})
|
||||
|
||||
@@ -519,6 +538,7 @@ def histodata(workouts, options):
|
||||
def cpdata(workouts, options):
|
||||
userid = options['userid']
|
||||
cpfit = options['cpfit']
|
||||
cpoverlay = options['cpoverlay']
|
||||
|
||||
u = User.objects.get(id=userid)
|
||||
r = u.rower
|
||||
@@ -546,6 +566,9 @@ def cpdata(workouts, options):
|
||||
|
||||
rowername = r.user.first_name+" "+r.user.last_name
|
||||
|
||||
wcdurations = []
|
||||
wcpower = []
|
||||
|
||||
if len(powerdf) !=0 :
|
||||
datefirst = pd.Series(w.date for w in workouts).min()
|
||||
datelast = pd.Series(w.date for w in workouts).max()
|
||||
@@ -561,19 +584,42 @@ def cpdata(workouts, options):
|
||||
# for Mike
|
||||
wtype = 'erg'
|
||||
|
||||
if cpoverlay:
|
||||
if r.birthdate:
|
||||
age = calculate_age(r.birthdate)
|
||||
else:
|
||||
worldclasspower = None
|
||||
age = 0
|
||||
|
||||
agerecords = CalcAgePerformance.objects.filter(
|
||||
age = age,
|
||||
sex = r.sex,
|
||||
weightcategory = r.weightcategory
|
||||
)
|
||||
|
||||
if len(agerecords) == 0:
|
||||
wcpower = []
|
||||
wcdurations = []
|
||||
else:
|
||||
wcdurations = []
|
||||
wcpower = []
|
||||
for record in agerecords:
|
||||
recordpower = record.power
|
||||
if wtype == 'water':
|
||||
recordpower = record.power*(100.-r.otwslack)/100.
|
||||
|
||||
wcdurations.append(record.duration)
|
||||
wcpower.append(recordpower)
|
||||
|
||||
res = interactive_otwcpchart(powerdf,promember=True,rowername=rowername,r=r,
|
||||
cpfit=cpfit,title=title,type=wtype)
|
||||
cpfit=cpfit,title=title,type=wtype,
|
||||
cpoverlay=cpoverlay,
|
||||
wcdurations=wcdurations,wcpower=wcpower)
|
||||
|
||||
script = res[0]
|
||||
div = res[1]
|
||||
p1 = res[2]
|
||||
ratio = res[3]
|
||||
#r.p0 = p1[0]
|
||||
#r.p1 = p1[1]
|
||||
#r.p2 = p1[2]
|
||||
#r.p3 = p1[3]
|
||||
#r.cpratio = ratio
|
||||
#r.save()
|
||||
paulslope = 1
|
||||
paulintercept = 1
|
||||
message = res[4]
|
||||
@@ -2194,7 +2240,7 @@ def rankings_view2(request,userid=0,
|
||||
if len(agerecords) == 0:
|
||||
recalc = True
|
||||
wcpower = []
|
||||
wcduration = []
|
||||
wcdurations = []
|
||||
else:
|
||||
wcdurations = []
|
||||
wcpower = []
|
||||
|
||||
Reference in New Issue
Block a user