diff options
author | Chris Schlaeger <chris@linux.com> | 2016-01-18 02:14:22 +0100 |
---|---|---|
committer | Chris Schlaeger <chris@linux.com> | 2016-01-18 02:14:22 +0100 |
commit | a938fda631bbc517cdc1c378de7f05421b4478f7 (patch) | |
tree | a9102ee1a05f00b6a06955b872ff35f66398273a | |
parent | fefca0e2a692cb8f296a105ac363ec5675b5d8f7 (diff) | |
download | postrunner-a938fda631bbc517cdc1c378de7f05421b4478f7.zip |
NEW: Improved handling of cycling activities
Don't show running specific metrics for cycling activities. Show
cadence in RPM instead.
These patches are based on patches by Brice Lopez.
-rw-r--r-- | lib/postrunner/ActivitySummary.rb | 31 | ||||
-rw-r--r-- | lib/postrunner/ChartView.rb | 54 |
2 files changed, 50 insertions, 35 deletions
diff --git a/lib/postrunner/ActivitySummary.rb b/lib/postrunner/ActivitySummary.rb index d7aa8dd..dd4abdf 100644 --- a/lib/postrunner/ActivitySummary.rb +++ b/lib/postrunner/ActivitySummary.rb @@ -81,18 +81,25 @@ module PostRunner "#{session.avg_heart_rate} bpm" : '-' ]) t.row([ 'Max. HR:', session.max_heart_rate ? "#{session.max_heart_rate} bpm" : '-' ]) - t.row([ 'Avg. Run Cadence:', - session.avg_running_cadence ? - "#{(2 * session.avg_running_cadence).round} spm" : '-' ]) - t.row([ 'Avg. Vertical Oscillation:', - local_value(session, 'avg_vertical_oscillation', '%.1f %s', - { :metric => 'cm', :statute => 'in' }) ]) - t.row([ 'Avg. Ground Contact Time:', - session.avg_stance_time ? - "#{session.avg_stance_time.round} ms" : '-' ]) - t.row([ 'Avg. Stride Length:', - local_value(session, 'avg_stride_length', '%.2f %s', - { :metric => 'm', :statute => 'ft' }) ]) + if @activity.sport == 'running' || @activity.sport == 'multisport' + t.row([ 'Avg. Run Cadence:', + session.avg_running_cadence ? + "#{(2 * session.avg_running_cadence).round} spm" : '-' ]) + t.row([ 'Avg. Vertical Oscillation:', + local_value(session, 'avg_vertical_oscillation', '%.1f %s', + { :metric => 'cm', :statute => 'in' }) ]) + t.row([ 'Avg. Ground Contact Time:', + session.avg_stance_time ? + "#{session.avg_stance_time.round} ms" : '-' ]) + t.row([ 'Avg. Stride Length:', + local_value(session, 'avg_stride_length', '%.2f %s', + { :metric => 'm', :statute => 'ft' }) ]) + end + if @activity.sport == 'cycling' + t.row([ 'Avg. Cadence:', + session.avg_candence ? + "#{(2 * session.avg_candence).round} rpm" : '-' ]) + end t.row([ 'Training Effect:', session.total_training_effect ? session.total_training_effect : '-' ]) diff --git a/lib/postrunner/ChartView.rb b/lib/postrunner/ChartView.rb index 8009954..58f35bb 100644 --- a/lib/postrunner/ChartView.rb +++ b/lib/postrunner/ChartView.rb @@ -49,10 +49,12 @@ module PostRunner chart_div(doc, 'hrv', 'R-R Intervals/Heart Rate Variability (ms)') #chart_div(doc, 'hrv_score', 'HRV Score (30s Window)') end - chart_div(doc, 'run_cadence', 'Run Cadence (spm)') - chart_div(doc, 'vertical_oscillation', - "Vertical Oscillation (#{select_unit('cm')})") - chart_div(doc, 'stance_time', 'Ground Contact Time (ms)') + if @sport == 'running' || @sport == 'multisport' + chart_div(doc, 'run_cadence', 'Run Cadence (spm)') + chart_div(doc, 'vertical_oscillation', + "Vertical Oscillation (#{select_unit('cm')})") + chart_div(doc, 'stance_time', 'Ground Contact Time (ms)') + end chart_div(doc, 'temperature', 'Temperature (°C)') end @@ -64,7 +66,8 @@ module PostRunner metric_unit when :statute { 'min/km' => 'min/mi', 'm' => 'ft', 'cm' => 'in', 'km/h' => 'mph', - 'bpm' => 'bpm', 'spm' => 'spm', 'ms' => 'ms' }[metric_unit] + 'bpm' => 'bpm', 'rpm' => 'rpm', 'spm' => 'spm', + 'ms' => 'ms' }[metric_unit] else Log.fatal "Unknown unit system #{@unit_system}" end @@ -116,24 +119,29 @@ EOT s << line_graph('hrv', 's', '', '#900000') #s << line_graph('hrv_score', 'HRV Score', '', '#900000') end - s << point_graph('run_cadence', 'Run Cadence', 'spm', - [ [ '#EE3F2D', 151 ], - [ '#F79666', 163 ], - [ '#A0D488', 174 ], - [ '#96D7DE', 185 ], - [ '#A88BBB', nil ] ]) - s << point_graph('vertical_oscillation', 'Vertical Oscillation', 'cm', - [ [ '#A88BBB', 67 ], - [ '#96D7DE', 84 ], - [ '#A0D488', 101 ], - [ '#F79666', 118 ], - [ '#EE3F2D', nil ] ]) - s << point_graph('stance_time', 'Ground Contact Time', 'ms', - [ [ '#A88BBB', 208 ], - [ '#96D7DE', 241 ], - [ '#A0D488', 273 ], - [ '#F79666', 305 ], - [ '#EE3F2D', nil ] ]) + if @sport == 'running' || @sport == 'multisport' + s << point_graph('run_cadence', 'Run Cadence', 'spm', + [ [ '#EE3F2D', 151 ], + [ '#F79666', 163 ], + [ '#A0D488', 174 ], + [ '#96D7DE', 185 ], + [ '#A88BBB', nil ] ]) + s << point_graph('vertical_oscillation', 'Vertical Oscillation', 'cm', + [ [ '#A88BBB', 67 ], + [ '#96D7DE', 84 ], + [ '#A0D488', 101 ], + [ '#F79666', 118 ], + [ '#EE3F2D', nil ] ]) + s << point_graph('stance_time', 'Ground Contact Time', 'ms', + [ [ '#A88BBB', 208 ], + [ '#96D7DE', 241 ], + [ '#A0D488', 273 ], + [ '#F79666', 305 ], + [ '#EE3F2D', nil ] ]) + end + if @sport == 'cycling' + s << line_graph('cadence', 'Cadence', 'rpm', '#A88BBB') + end s << line_graph('temperature', 'Temperature', 'C', '#444444') s << "\n});\n" |