Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
fix: Added duration and total_duration retreival from STD (#205)
Browse files Browse the repository at this point in the history
* fix: Added duration and total_duration retreival from STD

* Added fallback to MovingTime (always defined) for TimerTime and EndTime computation in STD activity download
  • Loading branch information
kevforget authored Sep 27, 2022
1 parent b56bc49 commit 1a161ea
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tapiriik/services/Decathlon/decathlon.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,14 @@ def DownloadActivityList(self, svcRecord, exhaustive=False):
activity.Type = self._reverseActivityTypeMappings[sport]
ride_data = ride["dataSummaries"]

activity.EndTime = activity.StartTime + timedelta(seconds=ride_data.get(self._unitMap["duration"]))
# "total_duration" might not be set, whereas "duration" is always set.
# We try to get the first one but we fallback to the second if it's None
timer_time = ride_data.get(self._unitMap["totalduration"], ride_data.get(self._unitMap["duration"]))

activity.Stats.MovingTime = ActivityStatistic(ActivityStatisticUnit.Seconds, value=ride_data.get(self._unitMap["duration"]))
activity.Stats.TimerTime = ActivityStatistic(ActivityStatisticUnit.Seconds, value=timer_time)
activity.EndTime = activity.StartTime + timedelta(seconds=timer_time)

activity.Stats.Distance = ActivityStatistic(ActivityStatisticUnit.Meters, value=ride_data.get(self._unitMap["distance"]))
activity.Stats.Energy = ActivityStatistic(ActivityStatisticUnit.Kilocalories, value=ride_data.get(self._unitMap["kcal"]))
activity.Stats.HR = ActivityStatistic(ActivityStatisticUnit.BeatsPerMinute, avg=ride_data.get(self._unitMap["hravg"]))
Expand Down

0 comments on commit 1a161ea

Please sign in to comment.