plans dedicated to rowers if possible
This commit is contained in:
@@ -1931,6 +1931,25 @@ description: ""
|
|||||||
self.assertEqual(self.ps_trimp.approximate_rscore,72)
|
self.assertEqual(self.ps_trimp.approximate_rscore,72)
|
||||||
|
|
||||||
|
|
||||||
|
@patch('rowers.garmin_stuff.requests.post', side_effect=mocked_requests)
|
||||||
|
@patch('rowers.utils.requests.post', side_effect=mocked_requests)
|
||||||
|
@patch('rowers.garmin_stuff.OAuth1Session', side_effect=MockOAuth1Session)
|
||||||
|
def test_plannedsession_steps_distance(self,mockpost,mock_post,MockOAuth1Session):
|
||||||
|
self.ps_trimp.interval_string = '10km'
|
||||||
|
self.ps_trimp.save()
|
||||||
|
|
||||||
|
self.assertEqual(self.ps_trimp.approximate_rscore,52)
|
||||||
|
|
||||||
|
@patch('rowers.garmin_stuff.requests.post', side_effect=mocked_requests)
|
||||||
|
@patch('rowers.utils.requests.post', side_effect=mocked_requests)
|
||||||
|
@patch('rowers.garmin_stuff.OAuth1Session', side_effect=MockOAuth1Session)
|
||||||
|
def test_plannedsession_steps_time(self,mockpost,mock_post,MockOAuth1Session):
|
||||||
|
self.ps_trimp.interval_string = '60min'
|
||||||
|
self.ps_trimp.save()
|
||||||
|
|
||||||
|
self.assertEqual(self.ps_trimp.approximate_rscore,60)
|
||||||
|
|
||||||
|
|
||||||
def test_plannedsessions_dateform_view(self):
|
def test_plannedsessions_dateform_view(self):
|
||||||
login = self.c.login(username=self.u.username, password=self.password)
|
login = self.c.login(username=self.u.username, password=self.password)
|
||||||
self.assertTrue(login)
|
self.assertTrue(login)
|
||||||
|
|||||||
@@ -599,13 +599,11 @@ def step_to_time_dist(step,avgspeed = 3.2,ftp=200,ftspm=25,ftv=3.7):
|
|||||||
except KeyError: # pragma: no cover
|
except KeyError: # pragma: no cover
|
||||||
targettype = 0
|
targettype = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if durationtype == 'Time':
|
if durationtype == 'Time':
|
||||||
value = step['durationValue']
|
value = step['durationValue']
|
||||||
seconds = value/1000.
|
seconds = value/1000.
|
||||||
distance = avgspeed*seconds
|
distance = avgspeed*seconds
|
||||||
|
rscore = 60.*seconds/3600.
|
||||||
|
|
||||||
if targettype == 'Speed':
|
if targettype == 'Speed':
|
||||||
value = step.get('targetValue',0)
|
value = step.get('targetValue',0)
|
||||||
@@ -663,6 +661,7 @@ def step_to_time_dist(step,avgspeed = 3.2,ftp=200,ftspm=25,ftv=3.7):
|
|||||||
value = step['durationValue']
|
value = step['durationValue']
|
||||||
distance = value/100.
|
distance = value/100.
|
||||||
seconds = distance/avgspeed
|
seconds = distance/avgspeed
|
||||||
|
rscore = 60*seconds/3600.
|
||||||
|
|
||||||
if targettype == 'Speed':
|
if targettype == 'Speed':
|
||||||
value = step.get('targetValue',0)
|
value = step.get('targetValue',0)
|
||||||
@@ -779,13 +778,19 @@ def ps_dict_order_dict(d,short=False):
|
|||||||
|
|
||||||
return sdict2
|
return sdict2
|
||||||
|
|
||||||
def ps_dict_order(d,short=False):
|
def ps_dict_order(d,short=False,rower=None):
|
||||||
sdict = collections.OrderedDict({})
|
sdict = collections.OrderedDict({})
|
||||||
steps = d['steps']
|
steps = d['steps']
|
||||||
|
|
||||||
|
ftp = 200
|
||||||
|
if rower is not None:
|
||||||
|
ftp = rower.ftp
|
||||||
|
# ftv = rower.ftv
|
||||||
|
# ftspm = rower.ftspm
|
||||||
|
|
||||||
for step in steps:
|
for step in steps:
|
||||||
sstring, type, stepID, repeatID, repeatValue = step_to_string(step,short=short)
|
sstring, type, stepID, repeatID, repeatValue = step_to_string(step,short=short)
|
||||||
seconds, meters,rscore = step_to_time_dist(step)
|
seconds, meters,rscore = step_to_time_dist(step,ftp=ftp)
|
||||||
|
|
||||||
sdict[stepID] = {
|
sdict[stepID] = {
|
||||||
'string':sstring,
|
'string':sstring,
|
||||||
|
|||||||
@@ -1477,6 +1477,13 @@ def plannedsessions_view(request,
|
|||||||
sessioncolor[ps.id] = cratiocolors[status]
|
sessioncolor[ps.id] = cratiocolors[status]
|
||||||
ws = Workout.objects.filter(user=r,plannedsession=ps)
|
ws = Workout.objects.filter(user=r,plannedsession=ps)
|
||||||
completiondate[ps.id] = cdate
|
completiondate[ps.id] = cdate
|
||||||
|
if ps.steps:
|
||||||
|
sdict, totalmeters, totalseconds, totalrscore = ps_dict_order(ps.steps,rower=r)
|
||||||
|
totals['planneddistance'] += int(totalmeters)
|
||||||
|
totals['plannedtime'] += int(totalseconds)/60.
|
||||||
|
totals['plannedrscore'] += int(totalrscore)
|
||||||
|
totals['plannedtrimp'] += int(totalrscore)*2
|
||||||
|
else:
|
||||||
if ps.sessionmode == 'distance':
|
if ps.sessionmode == 'distance':
|
||||||
totals['planneddistance'] += ps.sessionvalue
|
totals['planneddistance'] += ps.sessionvalue
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user