rojabo v2
This commit is contained in:
@@ -154,8 +154,8 @@ class InstrokeForm(forms.Form):
|
|||||||
metric = forms.ChoiceField(label='metric',choices=(('a','a'),('b','b')))
|
metric = forms.ChoiceField(label='metric',choices=(('a','a'),('b','b')))
|
||||||
individual_curves = forms.BooleanField(label='individual curves',initial=False,
|
individual_curves = forms.BooleanField(label='individual curves',initial=False,
|
||||||
required=False)
|
required=False)
|
||||||
spm_min = forms.IntegerField(initial=15,label='SPM Min',widget=HiddenInput)
|
spm_min = forms.FloatField(initial=15,label='SPM Min',widget=HiddenInput)
|
||||||
spm_max = forms.IntegerField(initial=45,label='SPM Max',widget=HiddenInput)
|
spm_max = forms.FloatField(initial=45,label='SPM Max',widget=HiddenInput)
|
||||||
activeminutesmin = forms.FloatField(
|
activeminutesmin = forms.FloatField(
|
||||||
required=False, initial=0, widget=forms.HiddenInput())
|
required=False, initial=0, widget=forms.HiddenInput())
|
||||||
activeminutesmax = forms.FloatField(
|
activeminutesmax = forms.FloatField(
|
||||||
|
|||||||
@@ -4318,6 +4318,9 @@ def instroke_interactive_chart(df,metric, workout, spm_min, spm_max,
|
|||||||
df_pos = (df+abs(df))/2.
|
df_pos = (df+abs(df))/2.
|
||||||
df_min = -(-df+abs(-df))/2.
|
df_min = -(-df+abs(-df))/2.
|
||||||
|
|
||||||
|
if df.empty:
|
||||||
|
return "", "No data in selection"
|
||||||
|
|
||||||
mean_vals = df.median().replace(0, np.nan)
|
mean_vals = df.median().replace(0, np.nan)
|
||||||
q75 = df_pos.quantile(q=0.75).replace(0,np.nan)
|
q75 = df_pos.quantile(q=0.75).replace(0,np.nan)
|
||||||
q25 = df_pos.quantile(q=0.25).replace(0,np.nan)
|
q25 = df_pos.quantile(q=0.25).replace(0,np.nan)
|
||||||
|
|||||||
@@ -169,6 +169,66 @@ aweekago = timezone.now()-timedelta(days=7)
|
|||||||
today = timezone.now()
|
today = timezone.now()
|
||||||
a_week_from_now = timezone.now()+timedelta(days=7)
|
a_week_from_now = timezone.now()+timedelta(days=7)
|
||||||
|
|
||||||
|
def stepsconvert(rojabo_steps, startid = 0, warmup = False, cooldown = False):
|
||||||
|
workout_steps = []
|
||||||
|
for step in rojabo_steps:
|
||||||
|
print(step)
|
||||||
|
durationtype = 'Time'
|
||||||
|
durationvalue = 10
|
||||||
|
if step['duration_type'] == 'seconds':
|
||||||
|
durationvalue = 1000*durationvalue # milliseconds
|
||||||
|
if step['duration_type'] == 'meters':
|
||||||
|
durationtype = 'Distance'
|
||||||
|
durationvalue = step['duration_value']*100 # centimeters
|
||||||
|
elif step['duration_type'] == 'strokes':
|
||||||
|
durationtype = 'Time'
|
||||||
|
try:
|
||||||
|
durationvalue = int(60.*step['duration_value']/step['stroke_rate'])
|
||||||
|
except TypeError:
|
||||||
|
try:
|
||||||
|
durationvalue = step['time']*1000
|
||||||
|
except KeyError:
|
||||||
|
durationvalue = 1000
|
||||||
|
|
||||||
|
intensity = 'Active'
|
||||||
|
if warmup:
|
||||||
|
intensity = 'Warmup'
|
||||||
|
if cooldown:
|
||||||
|
intensity = 'Cooldown'
|
||||||
|
targettype = 'Power'
|
||||||
|
targetvalue = step['target_value']
|
||||||
|
if targetvalue is None:
|
||||||
|
targettype = 'Cadence'
|
||||||
|
targetvalue = step['stroke_rate']
|
||||||
|
|
||||||
|
if step['target_type'] == 'rest':
|
||||||
|
targettype = ''
|
||||||
|
intensity = 'Rest'
|
||||||
|
targetvalue = 0
|
||||||
|
|
||||||
|
description = step['description']
|
||||||
|
|
||||||
|
if step['stroke_rate'] is not None:
|
||||||
|
description = description +' Stroke Rate {cadence} SPM'.format(
|
||||||
|
cadence = step['stroke_rate']
|
||||||
|
)
|
||||||
|
|
||||||
|
newstep = {
|
||||||
|
'stepId': startid,
|
||||||
|
'wkt_step_name': step['id'],
|
||||||
|
'durationType': durationtype,
|
||||||
|
'durationValue': durationvalue,
|
||||||
|
'targetType': targettype,
|
||||||
|
'targetvalue': targetvalue,
|
||||||
|
'intensity': intensity,
|
||||||
|
'description': description
|
||||||
|
}
|
||||||
|
startid += 1
|
||||||
|
workout_steps.append(newstep)
|
||||||
|
|
||||||
|
return workout_steps
|
||||||
|
|
||||||
|
|
||||||
def get_rojabo_workout_list(user,startdate=aweekago,enddate=a_week_from_now):
|
def get_rojabo_workout_list(user,startdate=aweekago,enddate=a_week_from_now):
|
||||||
r = Rower.objects.get(user=user)
|
r = Rower.objects.get(user=user)
|
||||||
if (r.rojabo_token == '') or (r.rojabo_token is None): # pragma: no cover
|
if (r.rojabo_token == '') or (r.rojabo_token is None): # pragma: no cover
|
||||||
@@ -190,7 +250,7 @@ def get_rojabo_workout_list(user,startdate=aweekago,enddate=a_week_from_now):
|
|||||||
date2 = enddate.strftime('%Y-%m-%d')
|
date2 = enddate.strftime('%Y-%m-%d')
|
||||||
|
|
||||||
|
|
||||||
url = ROJABO_OAUTH_LOCATION+'api/v1/training_sessions?from={date1}&to={date2}'.format(date1=date1,date2=date2)
|
url = ROJABO_OAUTH_LOCATION+'api/v2/training_sessions?from={date1}&to={date2}'.format(date1=date1,date2=date2)
|
||||||
|
|
||||||
response = requests.get(url, headers=headers)
|
response = requests.get(url, headers=headers)
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ $( function() {
|
|||||||
range: true,
|
range: true,
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 60,
|
max: 60,
|
||||||
|
step: 0.1,
|
||||||
values: [ {{ spm_min }}, {{ spm_max }} ],
|
values: [ {{ spm_min }}, {{ spm_max }} ],
|
||||||
slide: function( event, ui ) {
|
slide: function( event, ui ) {
|
||||||
$( "#amountspm" ).val(ui.values[ 0 ] + " - " + ui.values[ 1 ] );
|
$( "#amountspm" ).val(ui.values[ 0 ] + " - " + ui.values[ 1 ] );
|
||||||
|
|||||||
@@ -1113,13 +1113,23 @@ def workout_rojaboimport_view(request, message="", userid=0):
|
|||||||
ps.save()
|
ps.save()
|
||||||
# get steps if there are any
|
# get steps if there are any
|
||||||
steps = []
|
steps = []
|
||||||
if item['warm_up']:
|
try:
|
||||||
|
steps.append(rojabostuff.stepsconvert(item['warm_up']))
|
||||||
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
if item['primary']:
|
try:
|
||||||
|
steps.append(rojabostuff.stepsconvert(item['primary']))
|
||||||
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
if item['cool_down']:
|
try:
|
||||||
|
steps.append(rojabostuff.stepsconvert(item['cool_down']))
|
||||||
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if steps:
|
||||||
|
ps.steps = steps
|
||||||
|
ps.save()
|
||||||
|
|
||||||
messages.info(request,'Saved planned session {id}'.format(id=ps.id))
|
messages.info(request,'Saved planned session {id}'.format(id=ps.id))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user