From a938fda631bbc517cdc1c378de7f05421b4478f7 Mon Sep 17 00:00:00 2001 From: Chris Schlaeger Date: Mon, 18 Jan 2016 02:14:22 +0100 Subject: 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. --- lib/postrunner/ActivitySummary.rb | 31 +++++++++++++--------- lib/postrunner/ChartView.rb | 54 ++++++++++++++++++++++----------------- 2 files changed, 50 insertions(+), 35 deletions(-) (limited to 'lib') 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" -- cgit v1.2.3