diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-11-04 17:13:34 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-11-04 17:13:34 +0200 |
commit | 0a002b8d897047c7a9951c015af689896194c687 (patch) | |
tree | ba9897b83f8aec7f73accd537208c17ec9d6ca1c /app/models/commit.rb | |
parent | 98051316f821d99df2790709b364b3ecce19468e (diff) | |
download | gitlab-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.rb | 34 |
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? |