summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2018-03-04 21:31:53 +0100
committerChris Schlaeger <chris@linux.com>2018-03-04 21:31:53 +0100
commitca8a1fe5df72268f1110d74a928b4b33d1178f9a (patch)
treeca25e81bf0b47c5c537f1bdb5536b64db0e90498
parent48ba3947aef1b671c2cee46433d895134c778352 (diff)
downloadpostrunner-ca8a1fe5df72268f1110d74a928b4b33d1178f9a.zip
New: Show resting heart rate in profile section
-rw-r--r--lib/postrunner/ActivitySummary.rb4
-rw-r--r--lib/postrunner/UserProfileView.rb43
-rw-r--r--postrunner.gemspec2
3 files changed, 32 insertions, 17 deletions
diff --git a/lib/postrunner/ActivitySummary.rb b/lib/postrunner/ActivitySummary.rb
index dd6c40f..70546d8 100644
--- a/lib/postrunner/ActivitySummary.rb
+++ b/lib/postrunner/ActivitySummary.rb
@@ -361,6 +361,10 @@ module PostRunner
end
end
+ def trimp_exp
+
+ end
+
end
end
diff --git a/lib/postrunner/UserProfileView.rb b/lib/postrunner/UserProfileView.rb
index 93b23ae..e75ce18 100644
--- a/lib/postrunner/UserProfileView.rb
+++ b/lib/postrunner/UserProfileView.rb
@@ -24,14 +24,14 @@ module PostRunner
end
def to_html(doc)
- return nil if @fit_activity.user_profiles.empty?
+ return nil if @fit_activity.user_data.empty?
ViewFrame.new('user_profile', 'User Profile', 600, profile,
true).to_html(doc)
end
def to_s
- return '' if @fit_activity.user_profiles.empty?
+ return '' if @fit_activity.user_data.empty?
profile.to_s
end
@@ -39,31 +39,42 @@ module PostRunner
def profile
t = FlexiTable.new
- profile = @fit_activity.user_profiles.first
- if profile.height
+
+ user_data = @fit_activity.user_data.first
+ user_profile = @fit_activity.user_profiles.first
+ hr_zones = @fit_activity.heart_rate_zones.first
+
+ if user_data.height
unit = { :metric => 'm', :statute => 'ft' }[@unit_system]
- height = profile.get_as('height', unit)
+ height = user_data.get_as('height', unit)
t.cell('Height:', { :width => '40%' })
t.cell("#{'%.2f' % height} #{unit}", { :width => '60%' })
t.new_row
end
- if profile.weight
+ if user_data.weight
unit = { :metric => 'kg', :statute => 'lbs' }[@unit_system]
- weight = profile.get_as('weight', unit)
+ weight = user_data.get_as('weight', unit)
t.row([ 'Weight:', "#{'%.1f' % weight} #{unit}" ])
end
- t.row([ 'Gender:', profile.gender ]) if profile.gender
- t.row([ 'Age:', "#{profile.age} years" ]) if profile.age
- t.row([ 'Max. Heart Rate:', "#{profile.max_hr} bpm" ]) if profile.max_hr
- if (lthr = profile.running_lactate_threshold_heart_rate)
+ t.row([ 'Gender:', user_data.gender ]) if user_data.gender
+ t.row([ 'Age:', "#{user_data.age} years" ]) if user_data.age
+ if (user_profile && (rest_hr = user_profile.resting_heart_rate)) ||
+ (hr_zones && (rest_hr = hr_zones.resting_heart_rate))
+ t.row([ 'Resting Heart Rate:', "#{rest_hr} bpm" ])
+ end
+ if (max_hr = user_data.max_hr) ||
+ (max_hr = hr_zones.max_heart_rate)
+ t.row([ 'Max. Heart Rate:', "#{max_hr} bpm" ])
+ end
+ if (lthr = user_data.running_lactate_threshold_heart_rate)
t.row([ 'Running LTHR:', "#{lthr} bpm" ])
end
- if profile.activity_class
- t.row([ 'Activity Class:', profile.activity_class ])
+ if (activity_class = user_data.activity_class)
+ t.row([ 'Activity Class:', activity_class ])
end
- if profile.metmax
- t.row([ 'METmax:', "#{profile.metmax} MET" ])
- t.row([ 'VO2max:', "#{'%.1f' % (profile.metmax * 3.5)} ml/kg/min" ])
+ if (metmax = user_data.metmax)
+ t.row([ 'METmax:', "#{metmax} MET" ])
+ t.row([ 'VO2max:', "#{'%.1f' % (metmax * 3.5)} ml/kg/min" ])
end
t
end
diff --git a/postrunner.gemspec b/postrunner.gemspec
index 88deb07..5b7eb56 100644
--- a/postrunner.gemspec
+++ b/postrunner.gemspec
@@ -28,7 +28,7 @@ operating systems as well.}
spec.require_paths = ["lib"]
spec.required_ruby_version = '>=2.0'
- spec.add_dependency 'fit4ruby', '~> 2.0.0'
+ spec.add_dependency 'fit4ruby', '~> 3.0.0'
spec.add_dependency 'perobs', '~> 4.0.0'
spec.add_dependency 'nokogiri', '~> 1.6'