summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2017-09-03 17:54:29 +0200
committerChris Schlaeger <chris@linux.com>2017-09-03 17:54:29 +0200
commitde173fff12b2b9c20acd1a1dd1154eebf91e676c (patch)
treed484bf672334f32184464a16f64980ecc9248334 /lib
parent7a27b8c495b82a47cf8ec9e9caa72cf7bd25601f (diff)
downloadpostrunner-de173fff12b2b9c20acd1a1dd1154eebf91e676c.zip
New: Purge loaded FIT files during check operation.
This will significantly reduce the memory consumption and increases the check speed with several hundreds of FIT files.
Diffstat (limited to 'lib')
-rw-r--r--lib/postrunner/FFS_Activity.rb4
-rw-r--r--lib/postrunner/FitFileStore.rb17
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/postrunner/FFS_Activity.rb b/lib/postrunner/FFS_Activity.rb
index 46ea2bf..138912f 100644
--- a/lib/postrunner/FFS_Activity.rb
+++ b/lib/postrunner/FFS_Activity.rb
@@ -288,7 +288,9 @@ module PostRunner
end
end
- private
+ def purge_fit_file
+ @fit_activity = nil
+ end
end
diff --git a/lib/postrunner/FitFileStore.rb b/lib/postrunner/FitFileStore.rb
index ab6fefc..d5dba15 100644
--- a/lib/postrunner/FitFileStore.rb
+++ b/lib/postrunner/FitFileStore.rb
@@ -209,7 +209,17 @@ module PostRunner
@store['devices'].each do |id, device|
list += device.activities
end
- list.sort
+ # Sort the activites by timestamps (oldest to newest). As the list is
+ # composed from multiple devices, there is a small chance of identical
+ # timestamps. To guarantee a stable list, we use the long UID of the
+ # device in cases of identical timestamps.
+ list.sort! do |a1, a2|
+ a1.timestamp == a2.timestamp ?
+ a1.device.long_uid <=> a2.device.long_uid :
+ a1.timestamp <=> a2.timestamp
+ end
+
+ list
end
# Read in all Monitoring_B FIT files that overlap with the given interval.
@@ -305,11 +315,10 @@ module PostRunner
def check
records = @store['records']
records.delete_all_records
- activities.sort do |a1, a2|
- a1.timestamp <=> a2.timestamp
- end.each do |a|
+ activities.each do |a|
a.check
records.scan_activity_for_records(a)
+ a.purge_fit_file
end
records.generate_html_reports
generate_html_index_pages