Private
Public Access
1
0

added kfit and kfatigue to profile page

This commit is contained in:
Sander Roosendaal
2020-12-02 11:56:40 +01:00
parent 83e086056f
commit fe96b619e1
5 changed files with 36 additions and 20 deletions

View File

@@ -881,11 +881,17 @@ class Rower(models.Model):
ep3 = models.FloatField(default=1.0,verbose_name="erg CP p4")
ecpratio = models.FloatField(default=1.0,verbose_name="erg CP fit ratio")
cprange = models.IntegerField(default=42,verbose_name="Range for calculation breakthrough workouts and fitness (CP)",
cprange = models.IntegerField(default=42,verbose_name="Range for calculation of breakthrough workouts and fitness (CP)",
choices=cppresets)
otwslack = models.IntegerField(default=0,verbose_name="OTW Power slack")
# performance manager stuff
kfit = models.IntegerField(default=42,verbose_name='Fitness Time Decay Constant (days)')
kfatigue = models.IntegerField(default=7,verbose_name='Fatigue Time Decay Constant (days)')
showfit = models.BooleanField(default=False)
showfresh = models.BooleanField(default=False)
pw_ut2 = models.IntegerField(default=124,verbose_name="UT2 Power")
pw_ut1 = models.IntegerField(default=171,verbose_name="UT1 Power")
pw_at = models.IntegerField(default=203,verbose_name="AT Power")
@@ -2958,12 +2964,6 @@ class Workout(models.Model):
inboard = models.FloatField(default=0.88)
oarlength = models.FloatField(default=2.89)
# performance manager stuff
kfit = models.IntegerField(default=42)
kfatigue = models.IntegerField(default=7)
showfit = models.BooleanField(default=False)
showfresh = models.BooleanField(default=False)
notes = models.CharField(blank=True,null=True,max_length=1000)
summary = models.TextField(blank=True)
privacy = models.CharField(default='visible',max_length=30,
@@ -3623,7 +3623,7 @@ class RowerPowerForm(ModelForm):
class RowerCPForm(ModelForm):
class Meta:
model = Rower
fields = ['cprange']
fields = ['cprange','kfit','kfatigue']
# Form to set rower's Power zones, including test routines
# to enable consistency

View File

@@ -28,7 +28,7 @@
console.log(data);
// var parsedJSON = $.parseJSON(data); //
$("#id_script").replaceWith('<div id="id_script">'+data.script+'</d'+'iv>');
$("#id_chart").replaceWith('<div id="id_chart">'+data.div+'/d'+'iv>');
$("#id_chart").replaceWith('<div id="id_chart">'+data.div+'</d'+'iv>');
console.log('done');
}
});
@@ -109,6 +109,12 @@
on the left. The model balances out after a few weeks of regular training, so don't
make this chart shorter than a few months.
</p>
<p>
The time constants used in generating this performance chart were
a fitness decay constant of {{ rower.kfit }} days
and a fatigue decay constant of {{ rower.kfatigue }} days.
You can change these values in your <a href="/rowers/me/preferences/">Profile Settings</a>.
</p>
</li>
</ul>

View File

@@ -99,11 +99,14 @@
</li>
<li class="grid_2">
<form enctype="multipart/form-data" action="" method="post">
<h2>Range over which Critical Power rolling data (fitness) are calculated</h2>
<p>Use this form to change the number of weeks over which Rowsandall
keeps track of your Critical Power. </p>
<p>A shorter range will give you notifications of fitness improvements more often,
but will also quickly forget those breakthrough workouts.</p>
<h2>Fitness and Performance Manager Settings</h2>
<p>Use this form to change the parameters affecting your performance management.</p>
<p>A shorter range for the CP calculations
will give you notifications of fitness improvements more often,
but will also quickly forget those breakthrough workouts. Shorter decay
time constants for the performance manager will model a quicker building up
of fitness and a faster recovery. Recommended values are 42 days (fitness)
and 7 days (fatigue).</p>
<table>
{{ cpform.as_table }}
</table>

View File

@@ -1555,14 +1555,14 @@ def performancemanager_view(request,userid=0,mode='rower',
therower = getrequestrower(request,userid=userid)
theuser = therower.user
kfitness = 42
kfatigue = 7
kfitness = therower.kfit
kfatigue = therower.kfatigue
fitnesstest = 20
metricchoice = 'trimp'
modelchoice = 'tsb'
usefitscore = False
doform = False
dofatigue = False
doform = therower.showfresh
dofatigue = therower.showfit
if request.method == 'POST':
form = PerformanceManagerForm(request.POST)
@@ -1572,6 +1572,9 @@ def performancemanager_view(request,userid=0,mode='rower',
metricchoice = form.cleaned_data['metricchoice']
dofatigue = form.cleaned_data['dofatigue']
doform = form.cleaned_data['doform']
therower.showfresh = doform
therower.showfatigue = dofatigue
therower.save()
else:
form = PerformanceManagerForm()
@@ -1600,7 +1603,7 @@ def performancemanager_view(request,userid=0,mode='rower',
'script':script,
'div':thediv,
})
return(HttpResponse(response,content_type='application/json'))

View File

@@ -570,9 +570,13 @@ def rower_prefs_view(request,userid=0,message=""):
if cpform.is_valid():
cd = cpform.cleaned_data
cprange = cd['cprange']
kfit = cd['kfit']
kfatigue = cd['kfatigue']
r.cprange = cprange
r.kfit = kfit
r.kfatigue = kfatigue
r.save()
messages.info(request,'Updated CP range value')
messages.info(request,'Updated CP range and time decay constants')
success = dataprep.update_rolling_cp(r,mytypes.otwtypes,'water')
success = dataprep.update_rolling_cp(r,mytypes.otetypes,'erg')