diff options
-rw-r--r-- | lib/postrunner/ActivitiesDB.rb | 6 | ||||
-rw-r--r-- | lib/postrunner/Activity.rb | 13 | ||||
-rw-r--r-- | lib/postrunner/PersonalRecords.rb | 2 |
3 files changed, 20 insertions, 1 deletions
diff --git a/lib/postrunner/ActivitiesDB.rb b/lib/postrunner/ActivitiesDB.rb index 7f75fa6..929f8bd 100644 --- a/lib/postrunner/ActivitiesDB.rb +++ b/lib/postrunner/ActivitiesDB.rb @@ -168,6 +168,12 @@ module PostRunner def set(activity, attribute, value) activity.set(attribute, value) + if %w( norecord type ).include?(attribute) + # If we have changed a norecord setting or an activity type, we need + # to regenerate all reports and re-collect the record list since we + # don't know which Activity needs to replace the changed one. + check + end sync end diff --git a/lib/postrunner/Activity.rb b/lib/postrunner/Activity.rb index ff36d53..47390f5 100644 --- a/lib/postrunner/Activity.rb +++ b/lib/postrunner/Activity.rb @@ -28,7 +28,7 @@ module PostRunner @@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 ) + @@CachedAttributes = @@CachedActivityValues + %w( fit_file name norecord ) @@Schemata = { 'long_date' => Schema.new('long_date', 'Date', @@ -153,6 +153,8 @@ module PostRunner else if @@CachedActivityValues.include?(name_without_at) @unset_variables << name_without_at + elsif name_without_at == 'norecord' + @norecord = false else Log.fatal "Don't know how to initialize the instance variable " + "#{name_without_at}." @@ -233,6 +235,11 @@ module PostRunner ActivitySubTypes.values.join(', ') end @sub_sport = ActivitySubTypes.invert[value] + when 'norecord' + unless %w( true false).include?(value) + Log.fatal "norecord must either be 'true' or 'false'" + end + @norecord = value == 'true' else Log.fatal "Unknown activity attribute '#{attribute}'. Must be one of " + 'name, type or subtype' @@ -241,6 +248,10 @@ module PostRunner end def register_records + # If we have the @norecord flag set, we ignore this Activity for the + # record collection. + return if @norecord + distance_record = 0.0 distance_record_sport = nil # Array with popular distances (in meters) in ascending order. diff --git a/lib/postrunner/PersonalRecords.rb b/lib/postrunner/PersonalRecords.rb index 7f69529..66ef7e3 100644 --- a/lib/postrunner/PersonalRecords.rb +++ b/lib/postrunner/PersonalRecords.rb @@ -26,6 +26,7 @@ module PostRunner SpeedRecordDistances = { 'cycling' => { + 1000.0 => '1 km', 5000.0 => '5 km', 8000.0 => '8 km', 9000.0 => '9 km', @@ -328,6 +329,7 @@ module PostRunner "records-#{i}.html") RecordListPageView.new(@activities, record, max, i). write(output_file) + i += 1 end end |