summaryrefslogtreecommitdiff
path: root/app/models/commit_status.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-05-11 12:40:44 -0700
committerStan Hu <stanhu@gmail.com>2017-05-11 12:40:44 -0700
commite3bac7dffe87a6e5adb1b51700acedba09420515 (patch)
tree3cad0696bdfeb79609c0442f79708fbbed2d93f1 /app/models/commit_status.rb
parentf4b6bc06da18bce9553032463ca2012d7cad7268 (diff)
parente7e132529bff3af38175076b84c818b6dea4b05f (diff)
downloadgitlab-ce-sh-ajax-tests.tar.gz
Merge branch 'master' into sh-ajax-testssh-ajax-tests
Diffstat (limited to 'app/models/commit_status.rb')
-rw-r--r--app/models/commit_status.rb11
1 files changed, 3 insertions, 8 deletions
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) }