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") ep3 = models.FloatField(default=1.0,verbose_name="erg CP p4")
ecpratio = models.FloatField(default=1.0,verbose_name="erg CP fit ratio") 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) choices=cppresets)
otwslack = models.IntegerField(default=0,verbose_name="OTW Power slack") 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_ut2 = models.IntegerField(default=124,verbose_name="UT2 Power")
pw_ut1 = models.IntegerField(default=171,verbose_name="UT1 Power") pw_ut1 = models.IntegerField(default=171,verbose_name="UT1 Power")
pw_at = models.IntegerField(default=203,verbose_name="AT 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) inboard = models.FloatField(default=0.88)
oarlength = models.FloatField(default=2.89) 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) notes = models.CharField(blank=True,null=True,max_length=1000)
summary = models.TextField(blank=True) summary = models.TextField(blank=True)
privacy = models.CharField(default='visible',max_length=30, privacy = models.CharField(default='visible',max_length=30,
@@ -3623,7 +3623,7 @@ class RowerPowerForm(ModelForm):
class RowerCPForm(ModelForm): class RowerCPForm(ModelForm):
class Meta: class Meta:
model = Rower model = Rower
fields = ['cprange'] fields = ['cprange','kfit','kfatigue']
# Form to set rower's Power zones, including test routines # Form to set rower's Power zones, including test routines
# to enable consistency # to enable consistency

View File

@@ -28,7 +28,7 @@
console.log(data); console.log(data);
// var parsedJSON = $.parseJSON(data); // // var parsedJSON = $.parseJSON(data); //
$("#id_script").replaceWith('<div id="id_script">'+data.script+'</d'+'iv>'); $("#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'); console.log('done');
} }
}); });
@@ -109,6 +109,12 @@
on the left. The model balances out after a few weeks of regular training, so don't 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. make this chart shorter than a few months.
</p> </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> </li>
</ul> </ul>

View File

@@ -99,11 +99,14 @@
</li> </li>
<li class="grid_2"> <li class="grid_2">
<form enctype="multipart/form-data" action="" method="post"> <form enctype="multipart/form-data" action="" method="post">
<h2>Range over which Critical Power rolling data (fitness) are calculated</h2> <h2>Fitness and Performance Manager Settings</h2>
<p>Use this form to change the number of weeks over which Rowsandall <p>Use this form to change the parameters affecting your performance management.</p>
keeps track of your Critical Power. </p> <p>A shorter range for the CP calculations
<p>A shorter range will give you notifications of fitness improvements more often, will give you notifications of fitness improvements more often,
but will also quickly forget those breakthrough workouts.</p> 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> <table>
{{ cpform.as_table }} {{ cpform.as_table }}
</table> </table>

View File

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

View File

@@ -570,9 +570,13 @@ def rower_prefs_view(request,userid=0,message=""):
if cpform.is_valid(): if cpform.is_valid():
cd = cpform.cleaned_data cd = cpform.cleaned_data
cprange = cd['cprange'] cprange = cd['cprange']
kfit = cd['kfit']
kfatigue = cd['kfatigue']
r.cprange = cprange r.cprange = cprange
r.kfit = kfit
r.kfatigue = kfatigue
r.save() 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.otwtypes,'water')
success = dataprep.update_rolling_cp(r,mytypes.otetypes,'erg') success = dataprep.update_rolling_cp(r,mytypes.otetypes,'erg')