bug fixes and adding data download
This commit is contained in:
@@ -8,6 +8,7 @@ from __future__ import unicode_literals
|
|||||||
from __future__ import unicode_literals, absolute_import
|
from __future__ import unicode_literals, absolute_import
|
||||||
from rowers.models import (
|
from rowers.models import (
|
||||||
Workout, Team, CalcAgePerformance,C2WorldClassAgePerformance,
|
Workout, Team, CalcAgePerformance,C2WorldClassAgePerformance,
|
||||||
|
User
|
||||||
)
|
)
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
@@ -325,7 +326,9 @@ def workout_summary_to_df(
|
|||||||
startdate=datetime.datetime(1970,1,1),
|
startdate=datetime.datetime(1970,1,1),
|
||||||
enddate=timezone.now()+timezone.timedelta(days=1)):
|
enddate=timezone.now()+timezone.timedelta(days=1)):
|
||||||
|
|
||||||
ws = Workout.objects.filter(user=rower).order_by("startdatetime")
|
ws = Workout.objects.filter(
|
||||||
|
user=rower,date__gte=startdate,date__lte=enddate
|
||||||
|
).order_by("startdatetime")
|
||||||
|
|
||||||
types = []
|
types = []
|
||||||
names = []
|
names = []
|
||||||
@@ -339,6 +342,9 @@ def workout_summary_to_df(
|
|||||||
notes = []
|
notes = []
|
||||||
tcx_links = []
|
tcx_links = []
|
||||||
csv_links = []
|
csv_links = []
|
||||||
|
workout_links = []
|
||||||
|
goldstandards = []
|
||||||
|
goldstandarddurations = []
|
||||||
rscores = []
|
rscores = []
|
||||||
trimps = []
|
trimps = []
|
||||||
|
|
||||||
@@ -361,12 +367,20 @@ def workout_summary_to_df(
|
|||||||
id=encoder.encode_hex(w.id)
|
id=encoder.encode_hex(w.id)
|
||||||
)
|
)
|
||||||
csv_links.append(csv_link)
|
csv_links.append(csv_link)
|
||||||
|
workout_link = SITE_URL+'/rowers/workout/{id}/'.format(
|
||||||
|
id=encoder.encode_hex(w.id)
|
||||||
|
)
|
||||||
|
workout_links.append(workout_link)
|
||||||
trimps.append(workout_trimp(w)[0])
|
trimps.append(workout_trimp(w)[0])
|
||||||
rscore = workout_rscore(w)
|
rscore = workout_rscore(w)
|
||||||
rscores.append(int(rscore[0]))
|
rscores.append(int(rscore[0]))
|
||||||
|
goldstandard,goldstandardduration = workout_goldmedalstandard(w)
|
||||||
|
goldstandards.append(int(goldstandard))
|
||||||
|
goldstandarddurations.append(int(goldstandardduration))
|
||||||
|
|
||||||
df = pd.DataFrame({
|
df = pd.DataFrame({
|
||||||
'name':names,
|
'name':names,
|
||||||
|
'link':workout_links,
|
||||||
'date':startdatetimes,
|
'date':startdatetimes,
|
||||||
'timezone':timezones,
|
'timezone':timezones,
|
||||||
'type':types,
|
'type':types,
|
||||||
@@ -380,6 +394,8 @@ def workout_summary_to_df(
|
|||||||
'Stroke Data CSV':csv_links,
|
'Stroke Data CSV':csv_links,
|
||||||
'TRIMP Training Load':trimps,
|
'TRIMP Training Load':trimps,
|
||||||
'TSS Training Load':rscores,
|
'TSS Training Load':rscores,
|
||||||
|
'GS':goldstandards,
|
||||||
|
'GS_secs':goldstandarddurations,
|
||||||
})
|
})
|
||||||
|
|
||||||
return df
|
return df
|
||||||
@@ -1026,6 +1042,14 @@ from rowers.datautils import p0
|
|||||||
from rowers.utils import calculate_age
|
from rowers.utils import calculate_age
|
||||||
from scipy import optimize
|
from scipy import optimize
|
||||||
|
|
||||||
|
def get_workoutsummaries(userid,startdate):
|
||||||
|
u = User.objects.get(id=userid)
|
||||||
|
r = u.rower
|
||||||
|
df = workout_summary_to_df(r,startdate=startdate)
|
||||||
|
df = df.sort_values('date')
|
||||||
|
|
||||||
|
return df
|
||||||
|
|
||||||
def workout_goldmedalstandard(workout):
|
def workout_goldmedalstandard(workout):
|
||||||
if workout.goldmedalstandard > 0:
|
if workout.goldmedalstandard > 0:
|
||||||
return workout.goldmedalstandard,workout.goldmedalseconds
|
return workout.goldmedalstandard,workout.goldmedalseconds
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ def get_testpower(workouts,fitnesstestsecs,kfitness):
|
|||||||
fatigues.append(np.nan)
|
fatigues.append(np.nan)
|
||||||
fitnesses.append(np.nan)
|
fitnesses.append(np.nan)
|
||||||
|
|
||||||
return dates,testpower,fatigues,fitnesses
|
return dates,testpower, testduration,fatigues,fitnesses
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1714,6 +1714,7 @@ def performance_chart(user,startdate=None,enddate=None,kfitness=42,kfatigue=7,
|
|||||||
fitnesses = []
|
fitnesses = []
|
||||||
dates = []
|
dates = []
|
||||||
testpower = []
|
testpower = []
|
||||||
|
testduration = []
|
||||||
|
|
||||||
modelchoice = 'coggan'
|
modelchoice = 'coggan'
|
||||||
p0 = 0
|
p0 = 0
|
||||||
@@ -1722,11 +1723,10 @@ def performance_chart(user,startdate=None,enddate=None,kfitness=42,kfatigue=7,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fatigues,fitnesses,dates,testpower,testduration,impulses = getfatigues(fatigues,
|
||||||
fatigues,fitnesses,dates,testpower,impulses = getfatigues(fatigues,
|
|
||||||
fitnesses,
|
fitnesses,
|
||||||
dates,
|
dates,
|
||||||
testpower,
|
testpower,testduration,
|
||||||
startdate,enddate,
|
startdate,enddate,
|
||||||
user,metricchoice,
|
user,metricchoice,
|
||||||
kfatigue,kfitness)
|
kfatigue,kfitness)
|
||||||
|
|||||||
Reference in New Issue
Block a user