summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-11-04 17:13:34 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-11-04 17:13:34 +0200
commit0a002b8d897047c7a9951c015af689896194c687 (patch)
treeba9897b83f8aec7f73accd537208c17ec9d6ca1c /app/models/commit.rb
parent98051316f821d99df2790709b364b3ecce19468e (diff)
downloadgitlab-ci-0a002b8d897047c7a9951c015af689896194c687.tar.gz
Replace project scripts textarea with jobs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb34
1 files changed, 32 insertions, 2 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 08e2888..859522c 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -110,17 +110,47 @@ class Commit < ActiveRecord::Base
end
def builds_without_retry
- builds.where('id IN (SELECT MAX(id) FROM builds GROUP BY job_id)')
+ @builds_without_retry ||=
+ begin
+ grouped_builds = builds.group_by(&:job)
+ grouped_builds.map do |job, builds|
+ builds.sort_by(&:id).last
+ end
+ end
end
def status
- 'success'
+ if success?
+ 'success'
+ elsif running?
+ 'running'
+ elsif pending?
+ 'pending'
+ else
+ 'failed'
+ end
+ end
+
+ def pending?
+ builds_without_retry.all? do |build|
+ build.pending?
+ end
+ end
+
+ def running?
+ builds_without_retry.any? do |build|
+ build.running?
+ end
end
def success?
+ builds_without_retry.all? do |build|
+ build.success?
+ end
end
def failed?
+ status == 'failed'
end
def canceled?