diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/postrunner/DailyMonitoringAnalyzer.rb | 3 | ||||
-rw-r--r-- | lib/postrunner/Main.rb | 11 | ||||
-rw-r--r-- | lib/postrunner/MonitoringStatistics.rb | 8 |
3 files changed, 18 insertions, 4 deletions
diff --git a/lib/postrunner/DailyMonitoringAnalyzer.rb b/lib/postrunner/DailyMonitoringAnalyzer.rb index cb4b2d1..411bfdf 100644 --- a/lib/postrunner/DailyMonitoringAnalyzer.rb +++ b/lib/postrunner/DailyMonitoringAnalyzer.rb @@ -231,6 +231,9 @@ module PostRunner end end + unless @window_start_time + raise RuntimeError, "No window start time set for day #{day}" + end end end diff --git a/lib/postrunner/Main.rb b/lib/postrunner/Main.rb index 1e7ccb8..1544fd2 100644 --- a/lib/postrunner/Main.rb +++ b/lib/postrunner/Main.rb @@ -72,7 +72,10 @@ module PostRunner cfg['html_dir'] = File.join(@db_dir, 'html') setup_directories - return execute_command(args) + retval = execute_command(args) + @db.exit + + return retval rescue Exception => e if e.is_a?(SystemExit) || e.is_a?(Interrupt) @@ -621,10 +624,16 @@ EOT FileUtils.rm_rf(database_dir + '-new') end db.copy(database_dir + '-new', { :engine => PEROBS::FlatFileDB }) + db.exit + FileUtils.mv(database_dir, database_dir + '-old') FileUtils.mv(database_dir + '-new', database_dir) + db = PEROBS::Store.new(database_dir, { :engine => PEROBS::FlatFileDB }) db.check + db.exit + # TODO: Delete -old directory in some later version when we have some + # confidence that the conversion always works. Log.info "DB conversion completed successfully" end end diff --git a/lib/postrunner/MonitoringStatistics.rb b/lib/postrunner/MonitoringStatistics.rb index 507fcdc..3655b04 100644 --- a/lib/postrunner/MonitoringStatistics.rb +++ b/lib/postrunner/MonitoringStatistics.rb @@ -202,7 +202,7 @@ module PostRunner t.row([ 'Day', 'Steps', '% of', 'Goal', 'Wk. Int.', '% of', 'Floors', '% of', 'Floors', 'Dist.', 'Cals.' ]) t.row([ '', '', 'Goal', 'Steps', 'Minutes', '150', 'clmbd.', '10', - 'descd.', 'km', 'kCal' ]) + 'descd.', 'm', 'kCal' ]) t.body totals = Hash.new(0) counted_days = 0 @@ -213,7 +213,8 @@ module PostRunner day_str = time.strftime('%d %a') t.cell(day_str) - analyzer = DailyMonitoringAnalyzer.new(@monitoring_files, day_str) + analyzer = DailyMonitoringAnalyzer.new(@monitoring_files, + "#{year}-#{month}-#{dom}") steps_distance_calories = analyzer.steps_distance_calories steps = steps_distance_calories[:steps] @@ -310,7 +311,8 @@ module PostRunner day_str = time.strftime('%d %a') t.cell(day_str) - analyzer = DailySleepAnalyzer.new(@monitoring_files, day_str, + analyzer = DailySleepAnalyzer.new(@monitoring_files, + "#{year}-#{month}-#{dom}", -12 * 60 * 60) if (analyzer.sleep_cycles.empty?) |