Commit 068b1aee authored by Douwe Maan's avatar Douwe Maan

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
parents 5d3a0d38 b988644a
...@@ -13,6 +13,7 @@ module Ci ...@@ -13,6 +13,7 @@ module Ci
scope :ignore_failures, ->() { where(allow_failure: false) } scope :ignore_failures, ->() { where(allow_failure: false) }
scope :with_artifacts, ->() { where.not(artifacts_file: nil) } scope :with_artifacts, ->() { where.not(artifacts_file: nil) }
scope :with_expired_artifacts, ->() { with_artifacts.where('artifacts_expire_at < ?', Time.now) } 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_file, ArtifactUploader
mount_uploader :artifacts_metadata, ArtifactUploader mount_uploader :artifacts_metadata, ArtifactUploader
...@@ -25,10 +26,6 @@ module Ci ...@@ -25,10 +26,6 @@ module Ci
after_create :execute_hooks after_create :execute_hooks
class << self class << self
def last_month
where('created_at > ?', Date.today - 1.month)
end
def first_pending def first_pending
pending.unstarted.order('created_at ASC').first pending.unstarted.order('created_at ASC').first
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment