summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2014-11-17 01:42:45 +0100
committerChris Schlaeger <chris@linux.com>2014-11-17 01:42:45 +0100
commit70fa9815704d2552d9f24e1051566ad7773fda48 (patch)
treebd8edfb43ecbd3cbea8c0ebbb8402f37a0b93f04 /lib
parenta053e45fe0550305c6d84fe6a5af79a15df329e3 (diff)
downloadpostrunner-70fa9815704d2552d9f24e1051566ad7773fda48.zip
Adding support for activity sub types.
Diffstat (limited to 'lib')
-rw-r--r--lib/postrunner/Activity.rb40
-rw-r--r--lib/postrunner/ActivitySummary.rb2
-rw-r--r--lib/postrunner/ActivityView.rb4
3 files changed, 43 insertions, 3 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)