diff options
author | Greg Stark <stark@gitlab.com> | 2018-02-08 11:27:51 +0100 |
---|---|---|
committer | Greg Stark <stark@gitlab.com> | 2018-02-09 14:01:22 +0100 |
commit | 7b048631c6f53dd02e5c3b7175c30968f9d08db6 (patch) | |
tree | 59d666656f40e59764e0e2e40a12dd8dea7dab63 /app | |
parent | 271e7a325340551475ae937aaf2ed7a6344be9e8 (diff) | |
download | gitlab-ce-7b048631c6f53dd02e5c3b7175c30968f9d08db6.tar.gz |
WIP experiment
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/build.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index a5f6ec8b022..ba8d9944199 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -60,7 +60,9 @@ module Ci new = 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) - Ci::Build.from("(#{union.to_sql}) #{Ci::Build.table_name}") + # XXX + #Ci::Build.from("(#{union.to_sql}) #{Ci::Build.table_name}") + where(%Q[ci_builds.id IN (SELECT ci_builds.id FROM (#{union.to_sql}))]) end scope :with_artifacts_not_expired, ->() do @@ -68,7 +70,9 @@ module Ci new = 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) - Ci::Build.from("(#{union.to_sql}) #{Ci::Build.table_name}") + # XXX + #Ci::Build.from("(#{union.to_sql}) #{Ci::Build.table_name}") + where(%Q[ci_builds.id IN (SELECT ci_builds.id FROM (#{union.to_sql}))]) end scope :with_expired_artifacts, ->() do @@ -76,7 +80,9 @@ module Ci new = 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) - Ci::Build.from("(#{union.to_sql}) #{Ci::Build.table_name}") + # XXX + #Ci::Build.from("(#{union.to_sql}) #{Ci::Build.table_name}") + where(%Q[ci_builds.id IN (SELECT ci_builds.id FROM (#{union.to_sql}))]) end scope :last_month, ->() { where('created_at > ?', Date.today - 1.month) } |