From e11e292e9c72e5295b6b9918aaeab62310ef5904 Mon Sep 17 00:00:00 2001 From: Chris Schlaeger Date: Sun, 31 May 2020 16:49:08 +0200 Subject: Get age from user_profile instead of user_data if present --- lib/postrunner/UserProfileView.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/postrunner/UserProfileView.rb b/lib/postrunner/UserProfileView.rb index 4d45d94..988a2bf 100644 --- a/lib/postrunner/UserProfileView.rb +++ b/lib/postrunner/UserProfileView.rb @@ -46,16 +46,18 @@ module PostRunner user_profile = @fit_activity.user_profiles.first hr_zones = @fit_activity.heart_rate_zones.first - if user_data.height + if user_data && user_data.height unit = { :metric => 'm', :statute => 'ft' }[@unit_system] height = user_data.get_as('height', unit) t.cell('Height:', { :width => '40%' }) t.cell("#{'%.2f' % height} #{unit}", { :width => '60%' }) t.new_row end - if user_data.weight + if (user_data && user_data.weight) || + (user_profile && user_profile.weight) unit = { :metric => 'kg', :statute => 'lbs' }[@unit_system] - weight = user_data.get_as('weight', unit) + weight = (user_profile && user_profile.get_as('weight', unit)) || + (user_data && user_data.get_as('weight', unit)) t.row([ 'Weight:', "#{'%.1f' % weight} #{unit}" ]) end t.row([ 'Gender:', user_data.gender ]) if user_data.gender -- cgit v1.2.3