Changeset c555386 in OpenWorkouts-current for ow/models


Ignore:
Timestamp:
Jan 11, 2019, 11:56:20 AM (5 years ago)
Author:
borja <borja@…>
Branches:
current, feature/docs, master
Children:
d17dffe
Parents:
b73ae09
Message:

(#26) Several bugfixes when loading data from fit, then generating gpx code

from it:

  • Ensure track points are added to a generated gpx (from a fit file) if they exist.
  • Ensure ascent (uphill), descent (downhill) and distance data is added to the Workout object if there is any in the fit file (fixes loading fit files for indoor training without gps data on them)
  • Load the "sport" property from the fit file when loading data from fit into a Workout object
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/models/workout.py

    rb73ae09 rc555386  
    360360
    361361        # grab the needed data from the fit file, update the workout
     362        self.sport = fit.data['sport']
    362363        self.start = fit.data['start']
    363364        # ensure this datetime start object is timezone-aware
     
    365366        # duration comes in seconds, store a timedelta
    366367        self.duration = timedelta(seconds=fit.data['duration'])
    367         # distance comes in meters
    368         self.distance = Decimal(fit.data['distance']) / Decimal(1000.00)
    369         self.uphill = Decimal(fit.data['uphill'])
    370         self.downhill = Decimal(fit.data['downhill'])
     368        if fit.data['distance']:
     369            # distance comes in meters
     370            self.distance = Decimal(fit.data['distance']) / Decimal(1000.00)
     371        if fit.data['uphill']:
     372            self.uphill = Decimal(fit.data['uphill'])
     373        if fit.data['downhill']:
     374            self.downhill = Decimal(fit.data['downhill'])
    371375        # If the user did not provide us with a title, build one from the
    372376        # info in the fit file
Note: See TracChangeset for help on using the changeset viewer.