Changeset e0e2c10 in OpenWorkouts-current


Ignore:
Timestamp:
Jan 16, 2019, 12:57:09 PM (5 years ago)
Author:
borja <borja@…>
Branches:
current, feature/docs, master
Children:
eaef731
Parents:
ad5759b
Message:

Added attribute to store speed info for Workout objects.

Load avg and max speed from fit files into Workout objects.

Location:
ow
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ow/models/workout.py

    rad5759b re0e2c10  
    1212    copy_blob,
    1313    create_blob,
     14    mps_to_kmph
    1415)
    1516
     
    5051        self.duration = kw.get('duration', None)  # a timedelta object
    5152        self.distance = kw.get('distance', None)  # kilometers, Decimal
     53        self.speed = kw.get('speed', {})
    5254        self.hr_min = kw.get('hr_min', None)  # bpm, Decimal
    5355        self.hr_max = kw.get('hr_max', None)  # bpm, Decimal
     
    378380            self.title = fit.name
    379381
     382        if fit.data['max_speed']:
     383            self.speed['max'] = mps_to_kmph(fit.data['max_speed'])
     384
     385        if fit.data['avg_speed']:
     386            self.speed['avg'] = mps_to_kmph(fit.data['avg_speed'])
     387
    380388        if fit.data['avg_hr']:
    381389            self.hr_avg = Decimal(fit.data['avg_hr'])
  • ow/templates/workout.pt

    rad5759b re0e2c10  
    8787          <tal:c tal:content="context.rounded_distance"></tal:c> km
    8888        </li>
     89        <li tal:condition="context.speed">
     90          <tal:t i18n:translate="">Speed:</tal:t>
     91          <tal:t i18n:translate="">Avg.</tal:t>
     92          <tal:c tal:content="round(context.speed['avg'], 1)"></tal:c> km/h |
     93          <tal:t i18n:translate="">Max.</tal:t>
     94          <tal:c tal:content="round(context.speed['max'], 1)"></tal:c> km/h
     95        </li>
    8996        <li tal:condition="hr">
    9097          <tal:t i18n:translate="">Heart Rate:</tal:t>
Note: See TracChangeset for help on using the changeset viewer.