summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-07-07 22:47:48 +0000
committerDouwe Maan <douwe@gitlab.com>2016-07-07 22:47:48 +0000
commit068b1aeef94846fdcd96fe537ac5353cc0b6b198 (patch)
tree2ade3f7b462acaa0409f878789547b9c6eabf243
parent5d3a0d38cb7311a71433ddad2126a1eeddc5b31a (diff)
parentb988644ad853ea00ed23bfc57f83883f96a12016 (diff)
downloadgitlab-ce-068b1aeef94846fdcd96fe537ac5353cc0b6b198.tar.gz
Merge branch 'prefer-scope' into 'master'
Use scope rather than class method ## What does this MR do? Use scope rather than class method ## Why was this MR needed? I assume this would be useful and more clear. See merge request !5133
-rw-r--r--app/models/ci/build.rb5
1 files changed, 1 insertions, 4 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 5c973749975..e189dbac285 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -13,6 +13,7 @@ module Ci
scope :ignore_failures, ->() { where(allow_failure: false) }
scope :with_artifacts, ->() { where.not(artifacts_file: nil) }
scope :with_expired_artifacts, ->() { with_artifacts.where('artifacts_expire_at < ?', Time.now) }
+ scope :last_month, ->() { where('created_at > ?', Date.today - 1.month) }
mount_uploader :artifacts_file, ArtifactUploader
mount_uploader :artifacts_metadata, ArtifactUploader
@@ -25,10 +26,6 @@ module Ci
after_create :execute_hooks
class << self
- def last_month
- where('created_at > ?', Date.today - 1.month)
- end
-
def first_pending
pending.unstarted.order('created_at ASC').first
end