summaryrefslogtreecommitdiff
path: root/app/models/ci/pipeline.rb
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2019-04-16 12:54:47 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2019-04-16 12:54:47 +0000
commitc16619c527afdd00aa4dbbbf7544afb2f38477a8 (patch)
tree2d541ceff47cbd16a3a6ea72e0f5e65b0c7b633b /app/models/ci/pipeline.rb
parent29a53c4c31b8901f87818c86a9e8339334743616 (diff)
parent0cfa25ff21322d45aaef91fc7a3dd7c570632a05 (diff)
downloadgitlab-ce-c16619c527afdd00aa4dbbbf7544afb2f38477a8.tar.gz
Merge branch 'mc/feature/custom-metrics-ce' into 'master'
Backport metrics report type See merge request gitlab-org/gitlab-ce!26798
Diffstat (limited to 'app/models/ci/pipeline.rb')
-rw-r--r--app/models/ci/pipeline.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 0b1f119686a..b8edaf82c3d 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -210,6 +210,10 @@ module Ci
where(source: branch_pipeline_sources).where(ref: ref, tag: false)
end
+ scope :with_reports, -> (reports_scope) do
+ where('EXISTS (?)', ::Ci::Build.latest.with_reports(reports_scope).where('ci_pipelines.id=ci_builds.commit_id').select(1))
+ end
+
# Returns the pipelines in descending order (= newest first), optionally
# limited to a number of references.
#
@@ -689,13 +693,13 @@ module Ci
@latest_builds_with_artifacts ||= builds.latest.with_artifacts_not_expired.to_a
end
- def has_test_reports?
- complete? && builds.latest.with_test_reports.any?
+ def has_reports?(reports_scope)
+ complete? && builds.latest.with_reports(reports_scope).exists?
end
def test_reports
Gitlab::Ci::Reports::TestReports.new.tap do |test_reports|
- builds.latest.with_test_reports.each do |build|
+ builds.latest.with_reports(Ci::JobArtifact.test_reports).each do |build|
build.collect_test_reports!(test_reports)
end
end