Skip to content

Commit

Permalink
smashrun: fix lap calculation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
campbellr committed Jul 18, 2015
1 parent 607446e commit fce4c1b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tapiriik/services/Smashrun/smashrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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

Expand Down

0 comments on commit fce4c1b

Please sign in to comment.