short notation for workouts
This commit is contained in:
@@ -103,16 +103,16 @@ def ps_dict_get_durationdistance(d):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def ps_dict_get_description(d):
|
def ps_dict_get_description(d,short=False):
|
||||||
sdict,totalmeters,totalseconds = ps_dict_order(d)
|
sdict,totalmeters,totalseconds = ps_dict_order(d,short=short)
|
||||||
s = ''
|
s = ''
|
||||||
for item in sdict:
|
for item in sdict:
|
||||||
s += item['string']+'\n'
|
s += item['string']+'\n'
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def ps_dict_get_description_html(d):
|
def ps_dict_get_description_html(d,short=False):
|
||||||
sdict,totalmeters,totalseconds = ps_dict_order(d)
|
sdict,totalmeters,totalseconds = ps_dict_order(d,short=short)
|
||||||
|
|
||||||
s = '<ul>'
|
s = '<ul>'
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ favanalysisicons = {
|
|||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def steptostring(steps):
|
def steptostring(steps):
|
||||||
res = ps_dict_get_description_html(steps)
|
res = ps_dict_get_description_html(steps,short=True)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# for verbose version of fav analysis
|
# for verbose version of fav analysis
|
||||||
|
|||||||
112
rowers/utils.py
112
rowers/utils.py
@@ -669,11 +669,11 @@ def peel(l):
|
|||||||
return first,rest
|
return first,rest
|
||||||
|
|
||||||
|
|
||||||
def ps_dict_order_dict(d):
|
def ps_dict_order_dict(d,short=False):
|
||||||
steps = d['steps']
|
steps = d['steps']
|
||||||
sdicts = []
|
sdicts = []
|
||||||
for step in steps:
|
for step in steps:
|
||||||
sstring, type, stepID, repeatID, repeatValue = step_to_string(step)
|
sstring, type, stepID, repeatID, repeatValue = step_to_string(step,short=short)
|
||||||
seconds, meters = step_to_time_dist(step)
|
seconds, meters = step_to_time_dist(step)
|
||||||
|
|
||||||
sdict = {
|
sdict = {
|
||||||
@@ -689,12 +689,12 @@ def ps_dict_order_dict(d):
|
|||||||
|
|
||||||
return sdict2
|
return sdict2
|
||||||
|
|
||||||
def ps_dict_order(d):
|
def ps_dict_order(d,short=False):
|
||||||
sdict = collections.OrderedDict({})
|
sdict = collections.OrderedDict({})
|
||||||
steps = d['steps']
|
steps = d['steps']
|
||||||
|
|
||||||
for step in steps:
|
for step in steps:
|
||||||
sstring, type, stepID, repeatID, repeatValue = step_to_string(step)
|
sstring, type, stepID, repeatID, repeatValue = step_to_string(step,short=short)
|
||||||
seconds, meters = step_to_time_dist(step)
|
seconds, meters = step_to_time_dist(step)
|
||||||
|
|
||||||
sdict[stepID] = {
|
sdict[stepID] = {
|
||||||
@@ -711,7 +711,7 @@ def ps_dict_order(d):
|
|||||||
sdict2 = collections.OrderedDict(reversed(list(sdict.items())))
|
sdict2 = collections.OrderedDict(reversed(list(sdict.items())))
|
||||||
|
|
||||||
for step in steps:
|
for step in steps:
|
||||||
sstring, type, stepID, repeatID, repeatValue = step_to_string(step)
|
sstring, type, stepID, repeatID, repeatValue = step_to_string(step,short=short)
|
||||||
seconds, meters = step_to_time_dist(step)
|
seconds, meters = step_to_time_dist(step)
|
||||||
|
|
||||||
sdict[stepID] = {
|
sdict[stepID] = {
|
||||||
@@ -771,7 +771,7 @@ def ps_dict_order(d):
|
|||||||
|
|
||||||
return sdict,totalmeters,totalseconds
|
return sdict,totalmeters,totalseconds
|
||||||
|
|
||||||
def step_to_string(step):
|
def step_to_string(step,short=False):
|
||||||
type = 'Step'
|
type = 'Step'
|
||||||
repeatID = -1
|
repeatID = -1
|
||||||
repeatValue = 1
|
repeatValue = 1
|
||||||
@@ -804,14 +804,22 @@ def step_to_string(step):
|
|||||||
value = step['durationValue']
|
value = step['durationValue']
|
||||||
if value <= 100:
|
if value <= 100:
|
||||||
duration = 'until heart rate lower than {v}% of max'.format(v=value)
|
duration = 'until heart rate lower than {v}% of max'.format(v=value)
|
||||||
|
if short:
|
||||||
|
duration = 'until HR<{v}% of max'.format(v=value)
|
||||||
else:
|
else:
|
||||||
duration = 'until heart rate lower than {v}'.format(v=value-100)
|
duration = 'until heart rate lower than {v}'.format(v=value-100)
|
||||||
|
if short:
|
||||||
|
duration = 'until HR<{v}'.format(v=value-100)
|
||||||
elif durationtype == 'HrGreaterThan':
|
elif durationtype == 'HrGreaterThan':
|
||||||
value = step['durationValue']
|
value = step['durationValue']
|
||||||
if value <= 100:
|
if value <= 100:
|
||||||
duration = 'until heart rate greater than {v}% of max'.format(v=value)
|
duration = 'until heart rate greater than {v}% of max'.format(v=value)
|
||||||
|
if short:
|
||||||
|
duration = 'until R>{v}% of max'.format(v=value)
|
||||||
else:
|
else:
|
||||||
duration = 'until heart rate greater than {v}'.format(v=value-100)
|
duration = 'until heart rate greater than {v}'.format(v=value-100)
|
||||||
|
if short:
|
||||||
|
duration = 'until HR>{v}'.format(v=value/100)
|
||||||
elif durationtype == 'PowerLessThan':
|
elif durationtype == 'PowerLessThan':
|
||||||
value = step['durationValue']
|
value = step['durationValue']
|
||||||
targetvalue = step['targetvalue']
|
targetvalue = step['targetvalue']
|
||||||
@@ -819,10 +827,14 @@ def step_to_string(step):
|
|||||||
duration = 'Repeat until Power is less than {targetvalue} % of FTP'.format(
|
duration = 'Repeat until Power is less than {targetvalue} % of FTP'.format(
|
||||||
targetvalue=targetvalue
|
targetvalue=targetvalue
|
||||||
)
|
)
|
||||||
|
if short:
|
||||||
|
'until < {targetvalue}% of FTP'.format(targetvalue=targetvalue)
|
||||||
else:
|
else:
|
||||||
duration = 'Repeat until Power is less than {targetvalue} Watt'.format(
|
duration = 'Repeat until Power is less than {targetvalue} Watt'.format(
|
||||||
targetvalue=targetvalie
|
targetvalue=targetvalue-1000
|
||||||
)
|
)
|
||||||
|
if short:
|
||||||
|
'until < {targetvalue} W'.format(targetvalue=targetvalue-1000)
|
||||||
elif durationtype == 'PowerGreaterThan':
|
elif durationtype == 'PowerGreaterThan':
|
||||||
value = step['durationValue']
|
value = step['durationValue']
|
||||||
targetvalue = step['targetvalue']
|
targetvalue = step['targetvalue']
|
||||||
@@ -830,13 +842,19 @@ def step_to_string(step):
|
|||||||
duration = 'Repeat until Power is greater than {targetvalue} % of FTP'.format(
|
duration = 'Repeat until Power is greater than {targetvalue} % of FTP'.format(
|
||||||
targetvalue=targetvalue
|
targetvalue=targetvalue
|
||||||
)
|
)
|
||||||
|
if short:
|
||||||
|
duration = 'until > {targetvalue}% of FTP'.format(targetvalue=targetvalue)
|
||||||
else:
|
else:
|
||||||
duration = 'Repeat until Power is greater than {targetvalue} Watt'.format(
|
duration = 'Repeat until Power is greater than {targetvalue} Watt'.format(
|
||||||
targetvalue=targetvalie
|
targetvalue=targetvalue-1000
|
||||||
)
|
)
|
||||||
|
if short:
|
||||||
|
duration = 'until > {targetvalue} W'.format(targetvalue=targetvalue)
|
||||||
elif durationtype == 'RepeatUntilStepsCmplt':
|
elif durationtype == 'RepeatUntilStepsCmplt':
|
||||||
type = 'RepeatStep'
|
type = 'RepeatStep'
|
||||||
ntimes = str(step['targetValue'])+' times:'
|
ntimes = str(step['targetValue'])+' times:'
|
||||||
|
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']
|
||||||
@@ -847,10 +865,14 @@ def step_to_string(step):
|
|||||||
duration = 'Repeat until Heart Rate is greater than {targetvalue} % of max'.format(
|
duration = 'Repeat until Heart Rate is greater than {targetvalue} % of max'.format(
|
||||||
targetvalue=targetvalue
|
targetvalue=targetvalue
|
||||||
)
|
)
|
||||||
|
if short:
|
||||||
|
duration = ': until HR>{targervalue} % 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.
|
||||||
)
|
)
|
||||||
|
if short:
|
||||||
|
duration = ': untl HR>{targetvalue}'.format(targetvalue=targetvalue-100)
|
||||||
repeatID = step['durationValue']
|
repeatID = step['durationValue']
|
||||||
elif durationtype == 'RepeatUntilHrLessThan':
|
elif durationtype == 'RepeatUntilHrLessThan':
|
||||||
type = 'RepeatStep'
|
type = 'RepeatStep'
|
||||||
@@ -859,10 +881,14 @@ def step_to_string(step):
|
|||||||
duration = 'Repeat until Heart Rate is less than {targetvalue} % of max'.format(
|
duration = 'Repeat until Heart Rate is less than {targetvalue} % of max'.format(
|
||||||
targetvalue=targetvalue
|
targetvalue=targetvalue
|
||||||
)
|
)
|
||||||
|
if short:
|
||||||
|
duration = ': until HR<{targetvalue}% of max'.format(targetvalue=targetvalue)
|
||||||
else:
|
else:
|
||||||
duration = 'Repeat until Heart Rate is less than {targetvalue}:'.format(
|
duration = 'Repeat until Heart Rate is less than {targetvalue}:'.format(
|
||||||
targetvalue=targetvalue-100.
|
targetvalue=targetvalue-100.
|
||||||
)
|
)
|
||||||
|
if short:
|
||||||
|
duration = ': until HR<{targetvalue}'.format(targetvalue=targetvalue-100)
|
||||||
repeatID = step['durationValue']
|
repeatID = step['durationValue']
|
||||||
|
|
||||||
|
|
||||||
@@ -889,17 +915,29 @@ def step_to_string(step):
|
|||||||
|
|
||||||
if value < 10 and value>0:
|
if value < 10 and value>0:
|
||||||
target = 'Target: Heart Rate in zone {v}'.format(v=value)
|
target = 'Target: Heart Rate in 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 = 'Target: Heart Rate between {l} and {h} % of max'.format(
|
||||||
l = valuelow,
|
l = valuelow,
|
||||||
h = valuehigh
|
h = valuehigh
|
||||||
)
|
)
|
||||||
|
if short:
|
||||||
|
target = '@ HR {l} - {h} % of max'.format(
|
||||||
|
l = valuelow,
|
||||||
|
h = valuehigh,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
target = 'Target: Heart Rate between {l} and {h}'.format(
|
target = 'Target: Heart Rate between {l} and {h}'.format(
|
||||||
l = valuelow-100,
|
l = valuelow-100,
|
||||||
h = valuehigh+100
|
h = valuehigh+100
|
||||||
)
|
)
|
||||||
|
if short:
|
||||||
|
target = '@ HR {l} - {h}'.format(
|
||||||
|
l = valuelow - 100,
|
||||||
|
h = valuehigh - 100,
|
||||||
|
)
|
||||||
elif targettype == 'Power':
|
elif targettype == 'Power':
|
||||||
try:
|
try:
|
||||||
value = step['targetValue']
|
value = step['targetValue']
|
||||||
@@ -916,21 +954,37 @@ def step_to_string(step):
|
|||||||
|
|
||||||
if value < 10 and value>0:
|
if value < 10 and value>0:
|
||||||
target = 'Target: Power in zone {v}'.format(v=value)
|
target = 'Target: Power in 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 = 'Target: Power at {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 = 'Target: Power at {v} Watt'.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 = 'Target: Power between {l} and {h} % of FTP'.format(
|
||||||
l = valuelow,
|
l = valuelow,
|
||||||
h = valuehigh
|
h = valuehigh
|
||||||
)
|
)
|
||||||
|
if short:
|
||||||
|
target = '@ {l} - {h} % of FTP'.format(
|
||||||
|
l = valuelow,
|
||||||
|
h = valuehigh,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
target = 'Target: Power between {l} and {h} W'.format(
|
target = 'Target: Power between {l} and {h} W'.format(
|
||||||
l = valuelow-1000,
|
l = valuelow-1000,
|
||||||
h = valuehigh-1000
|
h = valuehigh-1000
|
||||||
)
|
)
|
||||||
|
if short:
|
||||||
|
target = '@ {l} - {h} W'.format(
|
||||||
|
l = valuelow-1000,
|
||||||
|
h = valuehigh-1000,
|
||||||
|
)
|
||||||
elif targettype == 'Speed':
|
elif targettype == 'Speed':
|
||||||
try:
|
try:
|
||||||
value = step['targetValue']
|
value = step['targetValue']
|
||||||
@@ -948,7 +1002,12 @@ def step_to_string(step):
|
|||||||
if value != 0:
|
if value != 0:
|
||||||
v = value/1000.
|
v = value/1000.
|
||||||
pace = 500./v
|
pace = 500./v
|
||||||
target = 'Target: Speed at {v} m/s'.format(v=value/1000.)
|
pacestring = to_pace(pace)
|
||||||
|
target = 'Target: Speed at {v} m/s {p} per 500m'.format(
|
||||||
|
v=value/1000.,
|
||||||
|
p=pacestring)
|
||||||
|
if short:
|
||||||
|
target = '@ {p}'.format(p=pacestring)
|
||||||
elif valuelow != 0 and valuehigh != 0:
|
elif valuelow != 0 and valuehigh != 0:
|
||||||
v = valuelow/1000.
|
v = valuelow/1000.
|
||||||
pace = 500./v
|
pace = 500./v
|
||||||
@@ -964,6 +1023,11 @@ def step_to_string(step):
|
|||||||
pl = pacestringlow,
|
pl = pacestringlow,
|
||||||
ph = pacestringhigh,
|
ph = pacestringhigh,
|
||||||
)
|
)
|
||||||
|
if short:
|
||||||
|
target = '@ {pl} - {ph}'.format(
|
||||||
|
pl = pacestringlow,
|
||||||
|
ph = pacestringhigh,
|
||||||
|
)
|
||||||
elif targettype == 'Cadence':
|
elif targettype == 'Cadence':
|
||||||
try:
|
try:
|
||||||
value = step['targetValue']
|
value = step['targetValue']
|
||||||
@@ -980,11 +1044,18 @@ def step_to_string(step):
|
|||||||
|
|
||||||
if value != 0:
|
if value != 0:
|
||||||
target = 'Target: Cadence at {v} SPM'.format(v=value)
|
target = 'Target: Cadence at {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 = 'Target: Cadence between {l} and {h} SPM'.format(
|
||||||
l = valuelow/1000.,
|
l = valuelow,
|
||||||
h = valuehigh/1000.,
|
h = valuehigh
|
||||||
)
|
)
|
||||||
|
if short:
|
||||||
|
target = '@ {l} - {h} SPM'.format(
|
||||||
|
l = valuelow,
|
||||||
|
h = valuehigh
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
nr = step['stepId']
|
nr = step['stepId']
|
||||||
@@ -1014,7 +1085,26 @@ def step_to_string(step):
|
|||||||
notes=notes,
|
notes=notes,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if short:
|
||||||
|
s = '{duration} {unit} {target} {repeat}'.format(
|
||||||
|
duration = duration,
|
||||||
|
target = target,
|
||||||
|
repeat = repeat,
|
||||||
|
unit = unit,
|
||||||
|
)
|
||||||
|
|
||||||
|
if short and intensity in ['Warmup','Cooldown','Rest']:
|
||||||
|
s = '{intensity} {duration} {unit} {target} {repeat}'.format(
|
||||||
|
intensity = intensity,
|
||||||
|
duration = duration,
|
||||||
|
target = target,
|
||||||
|
repeat = repeat,
|
||||||
|
unit = unit
|
||||||
|
)
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user