correcting bugs in gold medal score
This commit is contained in:
@@ -144,6 +144,7 @@ def all_goldmedalstandards(workouts,startdate,enddate):
|
||||
dates = []
|
||||
testpowers = []
|
||||
testduration = []
|
||||
ids = []
|
||||
|
||||
for w in workouts:
|
||||
goldmedalstandard, goldmedalseconds = dataprep.workout_goldmedalstandard(w)
|
||||
@@ -151,8 +152,9 @@ def all_goldmedalstandards(workouts,startdate,enddate):
|
||||
dates.append(arrow.get(w.date).datetime)
|
||||
testpowers.append(goldmedalstandard)
|
||||
testduration.append(goldmedalseconds)
|
||||
ids.append(w.id)
|
||||
|
||||
return dates,testpowers,testduration
|
||||
return dates,testpowers,testduration,ids
|
||||
|
||||
def build_goldmedalstandards(workouts,kfitness):
|
||||
dates = []
|
||||
@@ -1831,8 +1833,8 @@ def goldmedalscorechart(user,startdate=None,enddate=None):
|
||||
outids = df.mask(mask)['id'].dropna().unique()
|
||||
|
||||
# all workouts
|
||||
alldates,alltestpower,allduration = all_goldmedalstandards(workouts,startdate,enddate)
|
||||
allids = [w.id for w in workouts]
|
||||
alldates,alltestpower,allduration,allids = all_goldmedalstandards(workouts,startdate,enddate)
|
||||
|
||||
|
||||
nrdays = (enddate-startdate).days
|
||||
|
||||
@@ -1853,8 +1855,8 @@ def goldmedalscorechart(user,startdate=None,enddate=None):
|
||||
td.append(arrow.get(w.date).datetime)
|
||||
markerscore.append(testpower[i])
|
||||
markerduration.append(testduration[i])
|
||||
score.append(np.nan)
|
||||
duration.append(np.nan)
|
||||
score.append(testpower[i])
|
||||
duration.append(testduration[i])
|
||||
workoutid.append(id)
|
||||
|
||||
for i in range(len(alldates)):
|
||||
@@ -1883,14 +1885,19 @@ def goldmedalscorechart(user,startdate=None,enddate=None):
|
||||
'id':workoutid,
|
||||
})
|
||||
|
||||
df['url'] = df['id'].apply(lambda x:settings.SITE_URL+'/rowers/workout/{id}/'.format(id=encoder.encode_hex(x)))
|
||||
df['workout'] = df['id'].apply(lambda x:workoutname(x))
|
||||
|
||||
|
||||
df.sort_values(['date'],inplace=True)
|
||||
|
||||
df = df.groupby(['date']).max()
|
||||
df['date'] = df.index.values
|
||||
# find index values where score is max
|
||||
idx = df.groupby(['date'])['score'].transform(max) == df['score']
|
||||
df = df[idx]
|
||||
|
||||
#df = df.groupby(['date']).max()
|
||||
#df['date'] = df.index.values
|
||||
|
||||
df['url'] = df['id'].apply(lambda x:settings.SITE_URL+'/rowers/workout/{id}/'.format(id=encoder.encode_hex(x)))
|
||||
df['workout'] = df['id'].apply(lambda x:workoutname(x))
|
||||
|
||||
|
||||
source = ColumnDataSource(
|
||||
|
||||
Reference in New Issue
Block a user