Skip to content
代码片段 群组 项目
提交 8cbd94e2 编辑于 作者: Marius Bobin's avatar Marius Bobin
浏览文件

Merge branch 'morefice/filter-artifacts-partition-id' into 'master'

No related branches found
No related tags found
无相关合并请求
...@@ -115,43 +115,12 @@ class Build < Ci::Processable ...@@ -115,43 +115,12 @@ class Build < Ci::Processable
validates :ref, presence: true validates :ref, presence: true
scope :unstarted, -> { where(runner_id: nil) } scope :unstarted, -> { where(runner_id: nil) }
scope :with_any_artifacts, -> { where_exists(Ci::JobArtifact.scoped_build) }
scope :with_any_artifacts, -> do scope :with_downloadable_artifacts, -> { where_exists(Ci::JobArtifact.scoped_build.downloadable) }
where('EXISTS (?)', scope :with_erasable_artifacts, -> { where_exists(Ci::JobArtifact.scoped_build.erasable) }
Ci::JobArtifact.select(1).where("#{Ci::Build.quoted_table_name}.id = #{Ci::JobArtifact.quoted_table_name}.job_id") scope :with_existing_job_artifacts, ->(query) { where_exists(Ci::JobArtifact.scoped_build.erasable.merge(query)) }
)
end
scope :with_downloadable_artifacts, -> do
where('EXISTS (?)',
Ci::JobArtifact.select(1)
.where("#{Ci::Build.quoted_table_name}.id = #{Ci::JobArtifact.quoted_table_name}.job_id")
.where(file_type: Ci::JobArtifact::DOWNLOADABLE_TYPES)
)
end
scope :with_erasable_artifacts, -> do
where('EXISTS (?)',
Ci::JobArtifact.select(1)
.where("#{Ci::Build.quoted_table_name}.id = #{Ci::JobArtifact.quoted_table_name}.job_id")
.where(file_type: Ci::JobArtifact.erasable_file_types)
)
end
scope :in_pipelines, ->(pipelines) do
where(pipeline: pipelines)
end
scope :with_existing_job_artifacts, ->(query) do
where('EXISTS (?)', ::Ci::JobArtifact.select(1).where("#{Ci::Build.quoted_table_name}.id = #{Ci::JobArtifact.quoted_table_name}.job_id").merge(query))
end
scope :without_archived_trace, -> { where_not_exists(Ci::JobArtifact.scoped_build.trace) } scope :without_archived_trace, -> { where_not_exists(Ci::JobArtifact.scoped_build.trace) }
scope :with_artifacts, ->(artifact_scope) { with_existing_job_artifacts(artifact_scope).eager_load_job_artifacts }
scope :with_artifacts, ->(artifact_scope) do
with_existing_job_artifacts(artifact_scope)
.eager_load_job_artifacts
end
scope :eager_load_job_artifacts, -> { includes(:job_artifacts) } scope :eager_load_job_artifacts, -> { includes(:job_artifacts) }
scope :eager_load_tags, -> { includes(:tags) } scope :eager_load_tags, -> { includes(:tags) }
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册