Private
Public Access
1
0

sort of gets CP data

This commit is contained in:
Sander Roosendaal
2020-10-11 17:27:39 +02:00
parent 88107530a5
commit e0f11a3c1f
4 changed files with 132 additions and 3 deletions

View File

@@ -501,7 +501,58 @@ def histodata(workouts, options):
return(script,div)
def cpdata(workouts, options):
return ('','Not Yet Implemented')
userid = options['userid']
u = User.objects.get(id=userid)
r = u.rower
ids = [w.id for w in workouts]
delta, cpvalue, avgpower = dataprep.fetchcp_new(r,workouts)
powerdf = pd.DataFrame({
'Delta':delta,
'CP':cpvalue,
})
if powerdf.empty:
return('','<p>No valid data found</p>')
powerdf = powerdf[powerdf['CP']>0]
powerdf.dropna(axis=0,inplace=True)
powerdf.sort_values(['Delta','CP'],ascending=[1,0],inplace=True)
powerdf.drop_duplicates(subset='Delta',keep='first',inplace=True)
rowername = r.user.first_name+" "+r.user.last_name
if len(powerdf) !=0 :
res = interactive_otwcpchart(powerdf,promember=True,rowername=rowername)
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]
else:
script = ''
div = '<p>No ranking pieces found.</p>'
paulslope = 1
paulintercept = 1
p1 = [1,1,1,1]
message = ""
scripta = script.split('\n')[2:-1]
script = ''.join(scripta)
return (script,div)
def statsdata(workouts, options):
includereststrokes = options['includereststrokes']