diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index dd345736..8a82b6a5 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -572,8 +572,10 @@ def get_workout(user,c2id): if 'workout' in data: if 'splits' in data['workout']: splitdata = data['workout']['splits'] - if 'intervals' in data['workout']: + elif 'intervals' in data['workout']: splitdata = data['workout']['intervals'] + else: + splitdata = None # Check if workout has stroke data, and get the stroke data diff --git a/rowers/tests/c2jsonintervaldata.txt b/rowers/tests/c2jsonintervaldata.txt new file mode 100644 index 00000000..3c37d306 --- /dev/null +++ b/rowers/tests/c2jsonintervaldata.txt @@ -0,0 +1,64 @@ +{ + "date": "2017-05-01 14:33:00", + "timezone": "Australia/Melbourne", + "workout_type": "VariableInterval", + "type": "rower", + "weight_class": "H", + "time": 16800, + "distance": 6721, + "rest_distance": 236, + "rest_time": 2700, + "calories_total": 427, + "drag_factor": 175, + "stroke_count": 996, + "stroke_rate": 33, + "workout": { + "intervals": [ + { + "type": "time", + "time": 2400, + "distance": 1011, + "rest_time": 600, + "rest_distance": 43, + "stroke_rate": 35, + "calories_total": 68 + }, + { + "type": "time", + "time": 3000, + "distance": 1229, + "rest_time": 600, + "rest_distance": 59, + "stroke_rate": 34, + "calories_total": 80 + }, + { + "type": "time", + "time": 3000, + "distance": 1190, + "rest_time": 600, + "rest_distance": 59, + "stroke_rate": 33, + "calories_total": 75 + }, + { + "type": "time", + "time": 2400, + "distance": 971, + "rest_time": 750, + "rest_distance": 44, + "stroke_rate": 34, + "calories_total": 62 + }, + { + "type": "time", + "time": 6000, + "distance": 2320, + "rest_time": 150, + "rest_distance": 31, + "stroke_rate": 32, + "calories_total": 142 + } + ] + } +} diff --git a/rowers/tests/c2jsonsplitdata.txt b/rowers/tests/c2jsonsplitdata.txt new file mode 100644 index 00000000..ff6f9815 --- /dev/null +++ b/rowers/tests/c2jsonsplitdata.txt @@ -0,0 +1,47 @@ +{ + "date": "2017-05-16 17:24:00", + "timezone": "US/Pacific", + "workout_type": "FixedTimeSplits", + "type": "rower", + "weight_class": "H", + "time": 6000, + "distance": 1789, + "stroke_count": 314, + "drag_factor": 134, + "stroke_rate": 31, + "calories_total": 90, + "workout": { + "splits": [ + { + "time": 1200, + "calories_total": 18, + "stroke_rate": 33, + "distance": 354 + }, + { + "time": 1200, + "calories_total": 18, + "stroke_rate": 31, + "distance": 355 + }, + { + "time": 1200, + "calories_total": 18, + "stroke_rate": 32, + "distance": 357 + }, + { + "time": 1200, + "calories_total": 18, + "stroke_rate": 31, + "distance": 363 + }, + { + "time": 1200, + "calories_total": 18, + "stroke_rate": 30, + "distance": 361 + } + ] + } +} diff --git a/rowers/tests/testdata/testdata.csv.gz b/rowers/tests/testdata/testdata.csv.gz index 806101ec..bec967ba 100644 Binary files a/rowers/tests/testdata/testdata.csv.gz and b/rowers/tests/testdata/testdata.csv.gz differ diff --git a/rowers/tests/testdata/testdata.tcx b/rowers/tests/testdata/testdata.tcx index f54f4054..45a66625 100644 --- a/rowers/tests/testdata/testdata.tcx +++ b/rowers/tests/testdata/testdata.tcx @@ -2502,7 +2502,7 @@ - <Element 'Notes' at 0x187d63c8> + <Element 'Notes' at 0x1d49a6d8> diff --git a/rowers/views.py b/rowers/views.py index 4ebd4374..8e374356 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -11369,8 +11369,10 @@ def workout_getimportview(request,externalid,source = 'c2'): if 'workout' in data: if 'splits' in data['workout']: splitdata = data['workout']['splits'] - if 'intervals' in data['workout']: + elif 'intervals' in data['workout']: splitdata = data['workout']['intervals'] + else: + splitdata = False else: splitdata = False