API: max speed record fix

This commit is contained in:
Sam 2018-05-20 15:33:09 +02:00
parent e8d4ee2b6c
commit 5f98cfdc4a
3 changed files with 15 additions and 17 deletions

View File

@ -144,16 +144,14 @@ def get_gpx_info(gpx_file):
start = 0
for segment_idx, segment in enumerate(gpx.tracks[0].segments):
segment_max_speed = 0
segment_start = 0
for point_idx, point in enumerate(segment.points):
if point_idx == 0:
segment_start = point.time
if start == 0:
start = segment_start
segment_speed = segment.get_speed(point_idx)
if segment_speed > segment_max_speed:
segment_max_speed = segment_speed
if point_idx == 0 and start == 0:
start = point.time
segment_max_speed = (segment.get_moving_data().max_speed
if segment.get_moving_data().max_speed
else 0)
if segment_max_speed > max_speed:
max_speed = segment_max_speed
@ -163,8 +161,8 @@ def get_gpx_info(gpx_file):
segment_data['idx'] = segment_idx
gpx_data['segments'].append(segment_data)
gull_gpx_data = get_gpx_data(gpx, max_speed, start)
gpx_data = {**gpx_data, **gull_gpx_data}
full_gpx_data = get_gpx_data(gpx, max_speed, start)
gpx_data = {**gpx_data, **full_gpx_data}
bounds = gpx.get_bounds()
gpx_data['bounds'] = [
bounds.min_latitude,

View File

@ -13,7 +13,7 @@ def assert_activity_data_with_gpx(data):
assert data['data']['activities'][0]['descent'] == 23.4
assert data['data']['activities'][0]['distance'] == 0.32
assert data['data']['activities'][0]['max_alt'] == 998.0
assert data['data']['activities'][0]['max_speed'] == 5.09
assert data['data']['activities'][0]['max_speed'] == 5.11
assert data['data']['activities'][0]['min_alt'] == 975.0
assert data['data']['activities'][0]['moving'] == '0:04:10'
assert data['data']['activities'][0]['pauses'] is None
@ -29,7 +29,7 @@ def assert_activity_data_with_gpx(data):
assert segment['descent'] == 23.4
assert segment['distance'] == 0.32
assert segment['max_alt'] == 998.0
assert segment['max_speed'] == 5.09
assert segment['max_speed'] == 5.11
assert segment['min_alt'] == 975.0
assert segment['moving'] == '0:04:10'
assert segment['pauses'] is None
@ -40,7 +40,7 @@ def assert_activity_data_with_gpx(data):
assert records[0]['activity_id'] == 1
assert records[0]['record_type'] == 'MS'
assert records[0]['activity_date'] == 'Tue, 13 Mar 2018 12:44:45 GMT'
assert records[0]['value'] == 5.09
assert records[0]['value'] == 5.11
assert records[1]['sport_id'] == 1
assert records[1]['activity_id'] == 1
assert records[1]['record_type'] == 'LD'

View File

@ -12,7 +12,7 @@ def assert_activity_data_with_gpx(data):
assert data['data']['activities'][0]['descent'] == 23.4
assert data['data']['activities'][0]['distance'] == 0.32
assert data['data']['activities'][0]['max_alt'] == 998.0
assert data['data']['activities'][0]['max_speed'] == 5.09
assert data['data']['activities'][0]['max_speed'] == 5.11
assert data['data']['activities'][0]['min_alt'] == 975.0
assert data['data']['activities'][0]['moving'] == '0:04:10'
assert data['data']['activities'][0]['pauses'] is None
@ -24,7 +24,7 @@ def assert_activity_data_with_gpx(data):
assert records[0]['activity_id'] == 1
assert records[0]['record_type'] == 'MS'
assert records[0]['activity_date'] == 'Tue, 13 Mar 2018 12:44:45 GMT'
assert records[0]['value'] == 5.09
assert records[0]['value'] == 5.11
assert records[1]['sport_id'] == 2
assert records[1]['activity_id'] == 1
assert records[1]['record_type'] == 'LD'