improving long step description
This commit is contained in:
@@ -32,16 +32,7 @@ from rowingdata import rower as rrower
|
|||||||
|
|
||||||
from rowers.opaque import encoder
|
from rowers.opaque import encoder
|
||||||
|
|
||||||
def to_pace(pace):
|
from rowers.utils import to_pace
|
||||||
minutes, seconds = divmod(pace,60)
|
|
||||||
seconds, rest = divmod(seconds, 1)
|
|
||||||
tenths = int(rest*10)
|
|
||||||
s = '{m:0>2}:{s:0>2}.{t:0>1}'.format(
|
|
||||||
m=int(minutes),
|
|
||||||
s=int(seconds),
|
|
||||||
t=int(tenths)
|
|
||||||
)
|
|
||||||
return s
|
|
||||||
|
|
||||||
|
|
||||||
def to_time(milliseconds):
|
def to_time(milliseconds):
|
||||||
|
|||||||
@@ -105,6 +105,17 @@ info_calls = [
|
|||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
def to_pace(pace):
|
||||||
|
minutes, seconds = divmod(pace,60)
|
||||||
|
seconds, rest = divmod(seconds, 1)
|
||||||
|
tenths = int(rest*10)
|
||||||
|
s = '{m:0>2}:{s:0>2}.{t:0>1}'.format(
|
||||||
|
m=int(minutes),
|
||||||
|
s=int(seconds),
|
||||||
|
t=int(tenths)
|
||||||
|
)
|
||||||
|
return s
|
||||||
|
|
||||||
def get_call():
|
def get_call():
|
||||||
call1 = random.choice(coxes_calls)
|
call1 = random.choice(coxes_calls)
|
||||||
call2 = random.choice(info_calls)
|
call2 = random.choice(info_calls)
|
||||||
@@ -784,6 +795,7 @@ def step_to_string(step,short=False):
|
|||||||
unit = ''
|
unit = ''
|
||||||
target = ''
|
target = ''
|
||||||
repeat = ''
|
repeat = ''
|
||||||
|
notes = ''
|
||||||
|
|
||||||
durationtype = step['durationType']
|
durationtype = step['durationType']
|
||||||
if step['durationValue'] == 0:
|
if step['durationValue'] == 0:
|
||||||
@@ -854,9 +866,7 @@ def step_to_string(step,short=False):
|
|||||||
duration = 'until > {targetvalue} W'.format(targetvalue=targetvalue)
|
duration = 'until > {targetvalue} W'.format(targetvalue=targetvalue)
|
||||||
elif durationtype == 'RepeatUntilStepsCmplt':
|
elif durationtype == 'RepeatUntilStepsCmplt':
|
||||||
type = 'RepeatStep'
|
type = 'RepeatStep'
|
||||||
ntimes = str(step['targetValue'])+' times:'
|
ntimes = ': {v}x'.format(v=step['targetValue'])
|
||||||
if short:
|
|
||||||
ntimes = ': {v}x'.format(v=step['targetValue'])
|
|
||||||
repeatID = step['durationValue']
|
repeatID = step['durationValue']
|
||||||
duration =ntimes
|
duration =ntimes
|
||||||
repeatValue = step['targetValue']
|
repeatValue = step['targetValue']
|
||||||
@@ -868,7 +878,7 @@ def step_to_string(step,short=False):
|
|||||||
targetvalue=targetvalue
|
targetvalue=targetvalue
|
||||||
)
|
)
|
||||||
if short:
|
if short:
|
||||||
duration = ': until HR>{targervalue} % of max'.format(targetvalue=targetvalue)
|
duration = ': until HR>{targetvalue} % of max'.format(targetvalue=targetvalue)
|
||||||
else:
|
else:
|
||||||
duration = 'Repeat until Heart Rate is greater than {targetvalue}:'.format(
|
duration = 'Repeat until Heart Rate is greater than {targetvalue}:'.format(
|
||||||
targetvalue=targetvalue-100.
|
targetvalue=targetvalue-100.
|
||||||
@@ -916,27 +926,15 @@ def step_to_string(step,short=False):
|
|||||||
valuehigh = 0
|
valuehigh = 0
|
||||||
|
|
||||||
if value < 10 and value>0:
|
if value < 10 and value>0:
|
||||||
target = 'Target: Heart Rate in zone {v}'.format(v=value)
|
target = '@ HR zone {v}'.format(v=value)
|
||||||
if short:
|
|
||||||
target = '@ HR zone {v}'.format(v=value)
|
|
||||||
else:
|
else:
|
||||||
if valuelow < 100:
|
if valuelow < 100:
|
||||||
target = 'Target: Heart Rate between {l} and {h} % of max'.format(
|
target = '@ HR {l} - {h} % of max'.format(
|
||||||
l = valuelow,
|
|
||||||
h = valuehigh
|
|
||||||
)
|
|
||||||
if short:
|
|
||||||
target = '@ HR {l} - {h} % of max'.format(
|
|
||||||
l = valuelow,
|
l = valuelow,
|
||||||
h = valuehigh,
|
h = valuehigh,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
target = 'Target: Heart Rate between {l} and {h}'.format(
|
target = '@ HR {l} - {h}'.format(
|
||||||
l = valuelow-100,
|
|
||||||
h = valuehigh+100
|
|
||||||
)
|
|
||||||
if short:
|
|
||||||
target = '@ HR {l} - {h}'.format(
|
|
||||||
l = valuelow - 100,
|
l = valuelow - 100,
|
||||||
h = valuehigh - 100,
|
h = valuehigh - 100,
|
||||||
)
|
)
|
||||||
@@ -955,35 +953,19 @@ def step_to_string(step,short=False):
|
|||||||
valuehigh = 0
|
valuehigh = 0
|
||||||
|
|
||||||
if value < 10 and value>0:
|
if value < 10 and value>0:
|
||||||
target = 'Target: Power in zone {v}'.format(v=value)
|
target = '@ Power zone {v}'.format(v=value)
|
||||||
if short:
|
|
||||||
target = '@ Power zone {v}'.format(v=value)
|
|
||||||
elif value > 10 and value < 1000:
|
elif value > 10 and value < 1000:
|
||||||
target = 'Target: Power at {v} % of FTP'.format(v=value)
|
target = '@ {v}% of FTP'.format(v=value)
|
||||||
if short:
|
|
||||||
target = '@ {v}% of FTP'.format(v=value)
|
|
||||||
elif value > 1000:
|
elif value > 1000:
|
||||||
target = 'Target: Power at {v} Watt'.format(v=value-1000)
|
target = '@ {v} W'.format(v=value-1000)
|
||||||
if short:
|
|
||||||
target = '@ {v} W'.format(v=value-1000)
|
|
||||||
elif valuelow > 0 and valuehigh > 0:
|
elif valuelow > 0 and valuehigh > 0:
|
||||||
if valuelow < 1000:
|
if valuelow < 1000:
|
||||||
target = 'Target: Power between {l} and {h} % of FTP'.format(
|
target = '@ {l} - {h} % of FTP'.format(
|
||||||
l = valuelow,
|
|
||||||
h = valuehigh
|
|
||||||
)
|
|
||||||
if short:
|
|
||||||
target = '@ {l} - {h} % of FTP'.format(
|
|
||||||
l = valuelow,
|
l = valuelow,
|
||||||
h = valuehigh,
|
h = valuehigh,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
target = 'Target: Power between {l} and {h} W'.format(
|
target = '@ {l} - {h} W'.format(
|
||||||
l = valuelow-1000,
|
|
||||||
h = valuehigh-1000
|
|
||||||
)
|
|
||||||
if short:
|
|
||||||
target = '@ {l} - {h} W'.format(
|
|
||||||
l = valuelow-1000,
|
l = valuelow-1000,
|
||||||
h = valuehigh-1000,
|
h = valuehigh-1000,
|
||||||
)
|
)
|
||||||
@@ -1005,7 +987,7 @@ def step_to_string(step,short=False):
|
|||||||
v = value/1000.
|
v = value/1000.
|
||||||
pace = 500./v
|
pace = 500./v
|
||||||
pacestring = to_pace(pace)
|
pacestring = to_pace(pace)
|
||||||
target = 'Target: Speed at {v} m/s {p} per 500m'.format(
|
target = '@ {v} m/s {p}, per 500m'.format(
|
||||||
v=value/1000.,
|
v=value/1000.,
|
||||||
p=pacestring)
|
p=pacestring)
|
||||||
if short:
|
if short:
|
||||||
@@ -1019,7 +1001,7 @@ def step_to_string(step,short=False):
|
|||||||
pace = 500./v
|
pace = 500./v
|
||||||
pacestringhigh = to_pace(pace)
|
pacestringhigh = to_pace(pace)
|
||||||
|
|
||||||
target = 'Target: Speed between {l:1.2f} and {h:1.2f} m/s ({ph} to {pl} per 500m)'.format(
|
target = '@ {l:1.2f} and {h:1.2f} m/s, ({ph} to {pl} per 500m)'.format(
|
||||||
l = valuelow/1000.,
|
l = valuelow/1000.,
|
||||||
h = valuehigh/1000.,
|
h = valuehigh/1000.,
|
||||||
pl = pacestringlow,
|
pl = pacestringlow,
|
||||||
@@ -1045,16 +1027,9 @@ def step_to_string(step,short=False):
|
|||||||
valuehigh = 0
|
valuehigh = 0
|
||||||
|
|
||||||
if value != 0:
|
if value != 0:
|
||||||
target = 'Target: Cadence at {v} SPM'.format(v=value)
|
target = '@ {v} SPM'.format(v=value)
|
||||||
if short:
|
|
||||||
target = '@ {v} SPM'.format(v=value)
|
|
||||||
elif valuelow != 0 and valuehigh != 0:
|
elif valuelow != 0 and valuehigh != 0:
|
||||||
target = 'Target: Cadence between {l} and {h} SPM'.format(
|
target = '@ {l} - {h} SPM'.format(
|
||||||
l = valuelow,
|
|
||||||
h = valuehigh
|
|
||||||
)
|
|
||||||
if short:
|
|
||||||
target = '@ {l} - {h} SPM'.format(
|
|
||||||
l = valuelow,
|
l = valuelow,
|
||||||
h = valuehigh
|
h = valuehigh
|
||||||
)
|
)
|
||||||
@@ -1076,7 +1051,7 @@ def step_to_string(step,short=False):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
intensity = 0
|
intensity = 0
|
||||||
|
|
||||||
s = '{name} {intensity} {duration} {unit} {target} {repeat} {notes}'.format(
|
s = '{duration} {unit} {target} {repeat} {notes}'.format(
|
||||||
nr = nr,
|
nr = nr,
|
||||||
name = name,
|
name = name,
|
||||||
unit=unit,
|
unit=unit,
|
||||||
@@ -1103,10 +1078,17 @@ def step_to_string(step,short=False):
|
|||||||
repeat = repeat,
|
repeat = repeat,
|
||||||
unit = unit
|
unit = unit
|
||||||
)
|
)
|
||||||
|
elif intensity in ['Warmup','Cooldown','Rest']:
|
||||||
|
s = '{intensity} {duration} {unit} {target} {repeat} {notes}'.format(
|
||||||
|
intensity = intensity,
|
||||||
|
duration = duration,
|
||||||
|
target = target,
|
||||||
|
repeat = repeat,
|
||||||
|
unit = unit,
|
||||||
|
notes = notes,
|
||||||
|
)
|
||||||
|
|
||||||
if type == 'RepeatStep':
|
if type == 'RepeatStep':
|
||||||
s = 'Repeat {duration}'.format(duration=duration)
|
s = 'Repeat {duration}'.format(duration=duration)
|
||||||
if short:
|
|
||||||
s = 'Repeat {duration}'.format(duration=duration)
|
|
||||||
|
|
||||||
return s,type, nr, repeatID, repeatValue
|
return s,type, nr, repeatID, repeatValue
|
||||||
|
|||||||
@@ -2365,7 +2365,7 @@ def plannedsession_view(request,id=0,userid=0):
|
|||||||
steps = ''
|
steps = ''
|
||||||
if ps.steps:
|
if ps.steps:
|
||||||
d = ps.steps
|
d = ps.steps
|
||||||
steps = ps_dict_get_description_html(d)
|
steps = ps_dict_get_description_html(d,short=False)
|
||||||
|
|
||||||
|
|
||||||
return render(request,'plannedsessionview.html',
|
return render(request,'plannedsessionview.html',
|
||||||
|
|||||||
Reference in New Issue
Block a user