From 9802307e5efa8bc49d2619551870041d0bf2a685 Mon Sep 17 00:00:00 2001 From: jan-imrich <74548734+jan-imrich@users.noreply.github.com> Date: Wed, 18 Nov 2020 12:36:21 +0100 Subject: [PATCH] fix rounding problem Fixes the rounding problem. Since entry.hours is an getter with integrated round(2), its result should not be used for spent time calculation. Given the update function is called quite often (every 1-2 minutes), especially when the redmine issue is open in browser, it can disrupt the resulting overall logged time by up to 50%. --- lib/stopwatch/timer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/stopwatch/timer.rb b/lib/stopwatch/timer.rb index ae9d0ab..3147956 100644 --- a/lib/stopwatch/timer.rb +++ b/lib/stopwatch/timer.rb @@ -45,7 +45,7 @@ module Stopwatch # timestamp to either nil (stop: true) or current time. def update(stop: false) if hours = runtime_hours and entry = self.time_entry - time_entry.update_column :hours, entry.hours + hours + time_entry.update_column :hours, entry.read_attribute(:hours) + hours end data[:started_at] = stop || !running? ? nil : Time.now.to_i save