one more
This commit is contained in:
@@ -81,102 +81,129 @@ from rowers.tasks import (
|
||||
from rowers.utils import totaltime_sec_to_string
|
||||
|
||||
def step_to_string(step):
|
||||
|
||||
print(step)
|
||||
|
||||
target_dict = {
|
||||
'heart_rate': {
|
||||
'HeartRate': {
|
||||
'name':'Heart Rate between',
|
||||
'low':'custom_target_heart_rate_low',
|
||||
'high': 'custom_target_heart_rate_high'
|
||||
'low': 'custom_target_power_low',
|
||||
'high': 'custom_target_power_high',
|
||||
},
|
||||
'speed':{
|
||||
'Speed':{
|
||||
'name': 'Speed between',
|
||||
'low': 'custom_target_speed_low',
|
||||
'high': 'custom_target_speed_high',
|
||||
'low': 'custom_target_power_low',
|
||||
'high': 'custom_target_power_high',
|
||||
},
|
||||
'cadence':{
|
||||
'Cadence':{
|
||||
'name': 'SPM between',
|
||||
'low': 'custom_target_cadence_low',
|
||||
'high': 'custom_target_cadence_high',
|
||||
'low': 'custom_target_power_low',
|
||||
'high': 'custom_target_power_high',
|
||||
},
|
||||
'open':{
|
||||
'Open':{
|
||||
'name': 'between',
|
||||
'low': 'custom_target_value_low',
|
||||
'high': 'custom_target_value_high',
|
||||
'low': 'targetValueLow',
|
||||
'high': 'targetValueHigh',
|
||||
},
|
||||
'power':{
|
||||
'Power':{
|
||||
'name': 'Power between',
|
||||
'low': 'custom_target_power_low',
|
||||
'high': 'custom_target_power_high',
|
||||
},
|
||||
'stroke_type':{
|
||||
'SwimStroke':{
|
||||
'name': 'Stroke type',
|
||||
'low': 'target_swim_stroke',
|
||||
'high': '',
|
||||
},
|
||||
}
|
||||
|
||||
duration = ''
|
||||
repeat = ''
|
||||
target = ''
|
||||
intensity = ''
|
||||
nr = ''
|
||||
nr = 0
|
||||
name = ''
|
||||
intensity = ''
|
||||
duration = ''
|
||||
unit = ''
|
||||
target = ''
|
||||
repeat = ''
|
||||
|
||||
for key, value in step.items():
|
||||
durationtype = step['durationType']
|
||||
|
||||
if key == 'duration_distance':
|
||||
duration = '{v} m'.format(v=value)
|
||||
if key == 'duration_time':
|
||||
dd = timedelta(seconds=value)
|
||||
duration = '{v} min'.format(v=str(dd))
|
||||
if key in ['duration_hr']:
|
||||
duration = 'until HR reaches {v}'.format(v=value)
|
||||
if key == 'target_type' and value is not None:
|
||||
dd = target_dict[value]
|
||||
t = dd['name']
|
||||
l = ''
|
||||
h = ''
|
||||
try:
|
||||
if dd['low']:
|
||||
v = step[dd['low']]
|
||||
if value == 'heart_rate':
|
||||
if v<100:
|
||||
v = '{v} \%'.format(v=v)
|
||||
else:
|
||||
v = v-100
|
||||
v = '{v}'.format(v=v)
|
||||
l = '{v}'.format(v=v)
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
if dd['high']:
|
||||
v = step[dd['high']]
|
||||
if value == 'heart_rate':
|
||||
if v<100:
|
||||
v = '{v} \%'.format(v=v)
|
||||
else:
|
||||
v = v-100
|
||||
v = '{v}'.format(v=v)
|
||||
h = 'and {v}'.format(v=v)
|
||||
except KeyError:
|
||||
pass
|
||||
if durationtype == 'Time':
|
||||
unit = 'min'
|
||||
value = step['durationValue']
|
||||
dd = timedelta(seconds=value/1000.)
|
||||
duration = '{v}'.format(v=str(dd))
|
||||
elif durationtype == 'Distance':
|
||||
unit = 'm'
|
||||
value = step['durationValue']/100.
|
||||
duration = int(value)
|
||||
elif durationtype == 'HrLessThan':
|
||||
value = step['durationValue']
|
||||
if value < 100:
|
||||
duration = 'until heart rate lower than {v}% of max'.format(v=value)
|
||||
else:
|
||||
duration = 'until heart rate lower than {v}'.format(v=value-100)
|
||||
elif durationtype == 'HrGreaterThan':
|
||||
value = step['durationValue']
|
||||
if value < 100:
|
||||
duration = 'until heart rate greater than {v}% of max'.format(v=value)
|
||||
else:
|
||||
duration = 'until heart rate greater than {v}'.format(v=value-100)
|
||||
|
||||
target = '{t} {l} {h}'.format(
|
||||
t = t,
|
||||
l = l,
|
||||
h = h,
|
||||
)
|
||||
if key == 'intensity':
|
||||
intensity = '{v}'.format(v=value)
|
||||
if key == 'repeat':
|
||||
pass
|
||||
if key == 'message_index':
|
||||
nr = '{v}'.format(v=value)
|
||||
if key == 'wkt_step_name':
|
||||
name = '{v}'.format(v=value)
|
||||
targettype = step['targetType']
|
||||
|
||||
s = '{nr}: {name} {intensity} {duration} {target} {repeat}'.format(
|
||||
if targettype == 'HeartRate':
|
||||
value = step['targetValue']
|
||||
valuelow = step['targetValueLow']
|
||||
valuehigh = step['targetValueHigh']
|
||||
|
||||
if value < 10 and value>0:
|
||||
target = 'Target: Heart Rate in zone {v}'.format(v=value)
|
||||
else:
|
||||
if valuelow < 100:
|
||||
target = 'Target: Heart Rate between {l} and {h} % of max'.format(
|
||||
l = valuelow,
|
||||
h = valuehigh
|
||||
)
|
||||
else:
|
||||
target = 'Target: Heart Rate between {l} and {h}'.format(
|
||||
l = valuelow-100,
|
||||
h = valuehigh+100
|
||||
)
|
||||
elif targettype == 'Power':
|
||||
value = step['targetValue']
|
||||
valuelow = step['targetValueLow']
|
||||
valuehigh = step['targetValueHigh']
|
||||
|
||||
if value < 10 and value>0:
|
||||
target = 'Target: Power in zone {v}'.format(v=value)
|
||||
else:
|
||||
if valuelow < 1000:
|
||||
target = 'Target: Power between {l} and {h} % of FTP'.format(
|
||||
l = valuelow,
|
||||
h = valuehigh
|
||||
)
|
||||
else:
|
||||
target = 'Target: Power between {l} and {h} W'.format(
|
||||
l = valuelow-1000,
|
||||
h = valuehigh-1000
|
||||
)
|
||||
elif targettype == 'Speed':
|
||||
value = step['targetValue']
|
||||
valuelow = step['targetValueLow']
|
||||
valuehigh = step['targetValueHigh']
|
||||
|
||||
target = 'Target: Speed at {v} m/s'.format(v=value/1000.)
|
||||
|
||||
nr = step['stepId']
|
||||
|
||||
name = step['wkt_step_name']
|
||||
|
||||
intensity = step['intensity']
|
||||
|
||||
s = '{nr}: {name} {intensity} {duration} {unit} {target} {repeat}'.format(
|
||||
nr = nr,
|
||||
name = name,
|
||||
unit=unit,
|
||||
intensity = intensity,
|
||||
duration = duration,
|
||||
target=target,
|
||||
|
||||
Reference in New Issue
Block a user