summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2014-11-16 23:55:36 +0100
committerChris Schlaeger <chris@linux.com>2014-11-16 23:55:36 +0100
commita33244e3eac0505ed737617583e7a1aa5bfc32bf (patch)
treea55f9060567fb011f6786d50fc407b4e43323d1e
parentb5fbdd898233d5ec855f329941fd0be9b8b46a2c (diff)
downloadpostrunner-a33244e3eac0505ed737617583e7a1aa5bfc32bf.zip
Include activity type in activity list.
-rw-r--r--lib/postrunner/Activity.rb27
-rw-r--r--lib/postrunner/ActivityListView.rb5
2 files changed, 30 insertions, 2 deletions
diff --git a/lib/postrunner/Activity.rb b/lib/postrunner/Activity.rb
index d885a06..1c2213f 100644
--- a/lib/postrunner/Activity.rb
+++ b/lib/postrunner/Activity.rb
@@ -28,6 +28,29 @@ module PostRunner
# We also store some additional information in the archive index.
@@CachedAttributes = @@CachedActivityValues + %w( fit_file name )
+ @@ActivityTypes = {
+ 'generic' => 'Generic',
+ 'running' => 'Running',
+ 'cycling' => 'Cycling',
+ 'transition' => 'Transition',
+ 'fitness_equipment' => 'Fitness Equipment',
+ 'swimming' => 'Swimming',
+ 'basketball' => 'Basketball',
+ 'soccer' => 'Soccer',
+ 'tennis' => 'Tennis',
+ 'american_football' => 'American Football',
+ 'walking' => 'Walking',
+ 'cross_country_skiing' => 'Cross Country Skiing',
+ 'alpine_skiing' => 'Alpine Skiing',
+ 'snowboarding' => 'Snowboarding',
+ 'rowing' => 'Rowing',
+ 'mountaineering' => 'Mountaneering',
+ 'hiking' => 'Hiking',
+ 'multisport' => 'Multisport',
+ 'paddling' => 'Paddling',
+ 'all' => 'All'
+ }
+
def initialize(db, fit_file, fit_activity, name = nil)
@fit_file = fit_file
@fit_activity = fit_activity
@@ -140,6 +163,10 @@ module PostRunner
@db.successor(self))
end
+ def activity_type
+ @@ActivityTypes[@sport] || 'Undefined'
+ end
+
private
def load_fit_file(filter = nil)
diff --git a/lib/postrunner/ActivityListView.rb b/lib/postrunner/ActivityListView.rb
index 3c9f473..efcfc31 100644
--- a/lib/postrunner/ActivityListView.rb
+++ b/lib/postrunner/ActivityListView.rb
@@ -134,11 +134,11 @@ EOT
i = @page_no < 0 ? 0 : @page_no * @page_size
t = FlexiTable.new
t.head
- t.row(%w( Ref. Activity Start Distance Duration Speed/Pace ),
+ t.row(%w( Ref. Activity Type Start Distance Duration Speed/Pace ),
{ :halign => :left })
t.set_column_attributes([
{ :halign => :right },
- {}, {},
+ {}, {}, {},
{ :halign => :right },
{ :halign => :right },
{ :halign => :right }
@@ -151,6 +151,7 @@ EOT
t.row([
i += 1,
ActivityLink.new(a),
+ a.activity_type,
a.timestamp.strftime("%a, %Y %b %d %H:%M"),
local_value(a.total_distance, 'm', '%.2f',
{ :metric => 'km', :statute => 'mi' }),