diff options
Diffstat (limited to 'app/models/concerns/statuseable.rb')
-rw-r--r-- | app/models/concerns/statuseable.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/app/models/concerns/statuseable.rb b/app/models/concerns/statuseable.rb index 44c6b30f278..37efc44b79b 100644 --- a/app/models/concerns/statuseable.rb +++ b/app/models/concerns/statuseable.rb @@ -31,11 +31,6 @@ module Statuseable all.pluck(self.status_sql).first end - def duration - duration_array = all.map(&:duration).compact - duration_array.reduce(:+) - end - def started_at all.minimum(:started_at) end @@ -78,4 +73,14 @@ module Statuseable def complete? canceled? || success? || failed? end + + private + + def calculate_duration + if started_at && finished_at + finished_at - started_at + elsif started_at + Time.now - started_at + end + end end |