summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Stark <stark@gitlab.com>2018-02-09 18:22:05 +0100
committerGreg Stark <stark@gitlab.com>2018-02-09 18:22:05 +0100
commit660a9d33d13f6e95d50b76028a22fcc437b86d0b (patch)
tree5d5f592c0dbed6cb8d6e1c89cf7ccfff0b25ae75
parent82f9c1c429af118b6bcedfb60813e1ba741511d1 (diff)
downloadgitlab-ce-660a9d33d13f6e95d50b76028a22fcc437b86d0b.tar.gz
revert to earlier coding using a hard coded UNION ALL instead of Gitlab::SQL::Unionexpired-ci-artifacts
-rw-r--r--app/models/ci/build.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 836b9699cf5..7312e704932 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -59,24 +59,21 @@ module Ci
old = Ci::Build.select(:id).where(%q[artifacts_file <> ''])
new = Ci::Build.select(:id).where(%q[(artifacts_file IS NULL OR artifacts_file = '') AND EXISTS (?)],
Ci::JobArtifact.select(1).where('ci_builds.id = ci_job_artifacts.job_id'))
- union = Gitlab::SQL::Union.new([old, new], remove_duplicates: false)
- where(%Q[ci_builds.id IN (#{union.to_sql})]) # rubocop:disable GitlabSecurity/SqlInjection
+ where('ci_builds.id IN (? UNION ALL ?)', old, new)
end
scope :with_artifacts_not_expired, ->() do
old = Ci::Build.select(:id).where(%q[artifacts_file <> '' AND (artifacts_expire_at IS NULL OR artifacts_expire_at > ?)], Time.now)
new = Ci::Build.select(:id).where(%q[(artifacts_file IS NULL OR artifacts_file = '') AND EXISTS (?)],
Ci::JobArtifact.select(1).where('ci_builds.id = ci_job_artifacts.job_id AND (expire_at IS NULL OR expire_at > ?)', Time.now))
- union = Gitlab::SQL::Union.new([old, new], remove_duplicates: false)
- where(%Q[ci_builds.id IN (#{union.to_sql})]) # rubocop:disable GitlabSecurity/SqlInjection
+ where('ci_builds.id IN (? UNION ALL ?)', old, new)
end
scope :with_expired_artifacts, ->() do
old = Ci::Build.select(:id).where(%q[artifacts_file <> '' AND artifacts_expire_at < ?], Time.now)
new = Ci::Build.select(:id).where(%q[(artifacts_file IS NULL OR artifacts_file = '') AND EXISTS (?)],
Ci::JobArtifact.select(1).where('ci_builds.id = ci_job_artifacts.job_id AND expire_at < ?', Time.now))
- union = Gitlab::SQL::Union.new([old, new], remove_duplicates: false)
- where(%Q[ci_builds.id IN (#{union.to_sql})]) # rubocop:disable GitlabSecurity/SqlInjection
+ where('ci_builds.id IN (? UNION ALL ?)', old, new)
end
scope :last_month, ->() { where('created_at > ?', Date.today - 1.month) }