diff options
author | Regis Boudinot <boudinot.regis@yahoo.com> | 2017-05-10 22:07:05 +0000 |
---|---|---|
committer | Regis Boudinot <boudinot.regis@yahoo.com> | 2017-05-10 22:07:05 +0000 |
commit | 81df0034f4b66f2627ecd92f0ca44b7a3a634719 (patch) | |
tree | 1fc94d4e272b314dbe8b484e5c7d4cbf9faffb6c /app/models | |
parent | 4086fca0f4dba977874c4b79b46578d6d603bfc5 (diff) | |
parent | 7eaab72b983a89040a01b9f32184fef258fb29f2 (diff) | |
download | gitlab-ce-81df0034f4b66f2627ecd92f0ca44b7a3a634719.tar.gz |
Merge branch 'retried-in-database-mysql' into 'master'
Retried in database
Closes #25737
See merge request !11115
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build.rb | 4 | ||||
-rw-r--r-- | app/models/commit_status.rb | 11 |
2 files changed, 5 insertions, 10 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 971ab7cb0ee..3c4a4d93349 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -124,8 +124,8 @@ module Ci success? || failed? || canceled? end - def retried? - !self.pipeline.statuses.latest.include?(self) + def latest? + !retried? end def expanded_environment_name diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 75d04fd2b08..ffafc678968 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -18,13 +18,7 @@ class CommitStatus < ActiveRecord::Base validates :name, presence: true alias_attribute :author, :user - - scope :latest, -> do - max_id = unscope(:select).select("max(#{quoted_table_name}.id)") - - where(id: max_id.group(:name, :commit_id)) - end - + scope :failed_but_allowed, -> do where(allow_failure: true, status: [:failed, :canceled]) end @@ -37,7 +31,8 @@ class CommitStatus < ActiveRecord::Base false, all_state_names - [:failed, :canceled, :manual]) end - scope :retried, -> { where.not(id: latest) } + scope :latest, -> { where(retried: [false, nil]) } + scope :retried, -> { where(retried: true) } scope :ordered, -> { order(:name) } scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) } scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) } |