Skip to content

Commit

Permalink
Merge pull request #150 from campbellr/fix-laps
Browse files Browse the repository at this point in the history
smashrun: fix lap calculation
  • Loading branch information
cpfair committed Jul 18, 2015
2 parents 607446e + fce4c1b commit 206881d
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 206881d

Please sign in to comment.