summaryrefslogtreecommitdiff
path: root/app/models/concerns
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-08-10 22:45:30 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-08-10 23:12:02 +0800
commit21fdc1edaecf228c1fdc540375bbdad0fd69164a (patch)
tree8da76adcca752e497daa559ca7667787d20c3003 /app/models/concerns
parent831b6c8fda1adec32c0719500ad3e830284fb2af (diff)
downloadgitlab-ce-21fdc1edaecf228c1fdc540375bbdad0fd69164a.tar.gz
Cleanup the use of duration and optimize some queries
Diffstat (limited to 'app/models/concerns')
-rw-r--r--app/models/concerns/statuseable.rb15
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