From fce4c1be858707fc1d5fcbc2c2ab9cfda00ec7da Mon Sep 17 00:00:00 2001 From: Ryan Campbell Date: Fri, 17 Jul 2015 22:41:14 -0600 Subject: [PATCH] smashrun: fix lap calculation When converting a smashrun run into an Activity, i made some mistakes calculating the start time of a lap (every lap had the same start time), resulting in duplicate waypoints across laps. Among other things, the resulted in some weird graphs in activities synced from Smashrun to Garmin Connect. --- tapiriik/services/Smashrun/smashrun.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tapiriik/services/Smashrun/smashrun.py b/tapiriik/services/Smashrun/smashrun.py index 41a8d5f9b..9f6980f92 100644 --- a/tapiriik/services/Smashrun/smashrun.py +++ b/tapiriik/services/Smashrun/smashrun.py @@ -126,11 +126,12 @@ def DownloadActivity(self, serviceRecord, activity): # no laps, just make one big lap activity.Laps = [Lap(startTime=activity.StartTime, endTime=activity.EndTime, stats=activity.Stats)] - prevEndTime = activity.StartTime + startTime = activity.StartTime for lapRecord in act['laps']: - lap = Lap(startTime=prevEndTime, - endTime=prevEndTime + timedelta(seconds=lapRecord['endDuration'])) + endTime = activity.StartTime + timedelta(seconds=lapRecord['endDuration']) + lap = Lap(startTime=startTime, endTime=endTime) activity.Laps.append(lap) + startTime = endTime + timedelta(seconds=1) for value in zip(*act['recordingValues']): record = dict(zip(recordingKeys, value)) @@ -156,6 +157,7 @@ def DownloadActivity(self, serviceRecord, activity): for lap in activity.Laps: if lap.StartTime <= wp.Timestamp <= lap.EndTime: lap.Waypoints.append(wp) + break return activity