From a053e45fe0550305c6d84fe6a5af79a15df329e3 Mon Sep 17 00:00:00 2001 From: Chris Schlaeger Date: Mon, 17 Nov 2014 01:18:28 +0100 Subject: Add activity type to activity summary --- lib/postrunner/Activity.rb | 3 ++- lib/postrunner/ActivitySummary.rb | 8 +++++--- lib/postrunner/ActivityView.rb | 5 +++-- spec/ActivitySummary_spec.rb | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/postrunner/Activity.rb b/lib/postrunner/Activity.rb index 1c2213f..5f9d4fd 100644 --- a/lib/postrunner/Activity.rb +++ b/lib/postrunner/Activity.rb @@ -137,7 +137,8 @@ module PostRunner def summary @fit_activity = load_fit_file unless @fit_activity - puts ActivitySummary.new(@fit_activity, name, @db.cfg[:unit_system]).to_s + puts ActivitySummary.new(@fit_activity, @db.cfg[:unit_system], + { :name => @name, :type => activity_type }).to_s end def rename(name) diff --git a/lib/postrunner/ActivitySummary.rb b/lib/postrunner/ActivitySummary.rb index 57935b2..78c158f 100644 --- a/lib/postrunner/ActivitySummary.rb +++ b/lib/postrunner/ActivitySummary.rb @@ -22,9 +22,10 @@ module PostRunner include Fit4Ruby::Converters include ViewWidgets - def initialize(fit_activity, name, unit_system) + def initialize(fit_activity, unit_system, custom_fields) @fit_activity = fit_activity - @name = name + @name = custom_fields[:name] + @type = custom_fields[:type] @unit_system = unit_system end @@ -49,7 +50,8 @@ module PostRunner t = FlexiTable.new t.enable_frame(false) t.body - t.row([ 'Date:', session.timestamp]) + t.row([ 'Type:', @type ]) + t.row([ 'Date:', session.timestamp ]) t.row([ 'Distance:', local_value(session, 'total_distance', '%.2f %s', { :metric => 'km', :statute => 'mi'}) ]) diff --git a/lib/postrunner/ActivityView.rb b/lib/postrunner/ActivityView.rb index 790a0aa..b41e32d 100644 --- a/lib/postrunner/ActivityView.rb +++ b/lib/postrunner/ActivityView.rb @@ -42,8 +42,9 @@ module PostRunner private def generate_html(doc) - @report = ActivitySummary.new(@activity.fit_activity, @activity.name, - @unit_system) + @report = ActivitySummary.new(@activity.fit_activity, @unit_system, + { :name => @activity.name, + :type => @activity.activity_type }) @device_list = DeviceList.new(@activity.fit_activity) @user_profile = UserProfileView.new(@activity.fit_activity, @unit_system) @track_view = TrackView.new(@activity) diff --git a/spec/ActivitySummary_spec.rb b/spec/ActivitySummary_spec.rb index 20bbd3d..b2a8938 100644 --- a/spec/ActivitySummary_spec.rb +++ b/spec/ActivitySummary_spec.rb @@ -17,7 +17,8 @@ describe PostRunner::ActivitySummary do before(:each) do @as = PostRunner::ActivitySummary.new( - create_fit_activity('2014-08-26-19:00', 30), 'test', :metric) + create_fit_activity('2014-08-26-19:00', 30), :metric, + { :name => 'test', :type => 'Running' }) end it 'should create a metric summary' do -- cgit v1.2.3