diff options
-rw-r--r-- | lib/postrunner/Activity.rb | 40 | ||||
-rw-r--r-- | lib/postrunner/ActivitySummary.rb | 2 | ||||
-rw-r--r-- | lib/postrunner/ActivityView.rb | 4 | ||||
-rw-r--r-- | spec/ActivitySummary_spec.rb | 3 |
4 files changed, 45 insertions, 4 deletions
diff --git a/lib/postrunner/Activity.rb b/lib/postrunner/Activity.rb index 5f9d4fd..b3b55d4 100644 --- a/lib/postrunner/Activity.rb +++ b/lib/postrunner/Activity.rb @@ -23,7 +23,7 @@ module PostRunner # This is a list of variables that provide data from the fit file. To # speed up access to it, we cache the data in the activity database. - @@CachedActivityValues = %w( sport timestamp total_distance + @@CachedActivityValues = %w( sport sub_sport timestamp total_distance total_timer_time avg_speed ) # We also store some additional information in the archive index. @@CachedAttributes = @@CachedActivityValues + %w( fit_file name ) @@ -50,6 +50,36 @@ module PostRunner 'paddling' => 'Paddling', 'all' => 'All' } + @@ActivitySubTypes = { + 'generic' => 'Generic', + 'treadmill' => 'Treadmill', + 'street' => 'Street', + 'trail' => 'Trail', + 'track' => 'Track', + 'spin' => 'Spin', + 'indoor_cycling' => 'Indoor Cycling', + 'road' => 'Road', + 'mountain' => 'Mountain', + 'downhill' => 'Downhill', + 'recumbent' => 'Recumbent', + 'cyclocross' => 'Cyclocross', + 'hand_cycling' => 'Hand Cycling', + 'track_cycling' => 'Track Cycling', + 'indoor_rowing' => 'Indoor Rowing', + 'elliptical' => 'Elliptical', + 'stair_climbing' => 'Stair Climbing', + 'lap_swimming' => 'Lap Swimming', + 'open_water' => 'Open Water', + 'flexibility_training' => 'Flexibility Training', + 'strength_training' => 'Strength Traiming', + 'warm_up' => 'Warm up', + 'match' => 'Match', + 'exercise' => 'Excersize', + 'challenge' => 'Challenge', + 'indoor_skiing' => 'Indoor Skiing', + 'cardio_training' => 'Cardio Training', + 'all' => 'All' + } def initialize(db, fit_file, fit_activity, name = nil) @fit_file = fit_file @@ -138,7 +168,9 @@ module PostRunner def summary @fit_activity = load_fit_file unless @fit_activity puts ActivitySummary.new(@fit_activity, @db.cfg[:unit_system], - { :name => @name, :type => activity_type }).to_s + { :name => @name, + :type => activity_type, + :sub_type => activity_sub_type }).to_s end def rename(name) @@ -168,6 +200,10 @@ module PostRunner @@ActivityTypes[@sport] || 'Undefined' end + def activity_sub_type + @@ActivitySubTypes[@sub_sport] || 'Undefined' + end + private def load_fit_file(filter = nil) diff --git a/lib/postrunner/ActivitySummary.rb b/lib/postrunner/ActivitySummary.rb index 78c158f..ab283cb 100644 --- a/lib/postrunner/ActivitySummary.rb +++ b/lib/postrunner/ActivitySummary.rb @@ -26,6 +26,7 @@ module PostRunner @fit_activity = fit_activity @name = custom_fields[:name] @type = custom_fields[:type] + @sub_type = custom_fields[:sub_type] @unit_system = unit_system end @@ -51,6 +52,7 @@ module PostRunner t.enable_frame(false) t.body t.row([ 'Type:', @type ]) + t.row([ 'Sub Type:', @sub_type ]) t.row([ 'Date:', session.timestamp ]) t.row([ 'Distance:', local_value(session, 'total_distance', '%.2f %s', diff --git a/lib/postrunner/ActivityView.rb b/lib/postrunner/ActivityView.rb index b41e32d..fcca726 100644 --- a/lib/postrunner/ActivityView.rb +++ b/lib/postrunner/ActivityView.rb @@ -44,7 +44,9 @@ module PostRunner def generate_html(doc) @report = ActivitySummary.new(@activity.fit_activity, @unit_system, { :name => @activity.name, - :type => @activity.activity_type }) + :type => @activity.activity_type, + :sub_type => @activity.activity_sub_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 b2a8938..b09f6d3 100644 --- a/spec/ActivitySummary_spec.rb +++ b/spec/ActivitySummary_spec.rb @@ -18,7 +18,8 @@ describe PostRunner::ActivitySummary do before(:each) do @as = PostRunner::ActivitySummary.new( create_fit_activity('2014-08-26-19:00', 30), :metric, - { :name => 'test', :type => 'Running' }) + { :name => 'test', :type => 'Running', + :sub_type => 'Street' }) end it 'should create a metric summary' do |