Private
Public Access
1
0

c2 import adds rest distance

This commit is contained in:
Sander Roosendaal
2021-09-22 08:29:27 +02:00
parent e642ec10e9
commit ead4663131
3 changed files with 16 additions and 1 deletions

View File

@@ -3114,6 +3114,13 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone
splitdata = None
distance = data['distance']
try:
rest_distance = data['rest_distance']
rest_time = data['rest_time']/10.
except KeyError:
rest_distance = 0
rest_time = 0
distance = distance+rest_distance
c2id = data['id']
workouttype = data['type']
verified = data['verified']

View File

@@ -410,11 +410,13 @@ class C2Objects(DjangoTestCase):
self.assertEqual(str(timezone),'America/Los_Angeles')
got = arrow.get(startdatetime).isoformat()
want = arrow.get('2021-06-02 08:07:04.7-07:00').isoformat()
want = arrow.get('2021-06-02 07:51:14.600000-07:00').isoformat()
self.assertEqual(got, want)
self.assertEqual(workoutdate,'2021-06-02')
self.assertEqual(duration,'00:49:39.4')
def test_c2_import_54933639(self):
with open('rowers/tests/testdata/c2_54933639.json','r') as infile:
data = json.load(infile)

View File

@@ -1265,6 +1265,12 @@ def get_startdatetime_from_c2data(data):
startdatetime = iso8601.parse_date(data['date'])
totaltime = data['time']/10.
try:
rest_time = data['rest_time']/10.
except KeyError:
rest_time = 0
totaltime = totaltime+rest_time
duration = totaltime_sec_to_string(totaltime)
starttimeunix = arrow.get(startdatetime).timestamp()-totaltime
startdatetime = arrow.get(starttimeunix)