Commit 2530bc0c authored by Kamil Trzciński's avatar Kamil Trzciński

Support returning a new pipelines

parent c3ff1702
...@@ -5,7 +5,7 @@ module Projects ...@@ -5,7 +5,7 @@ module Projects
before_action :authorize_read_project_security_dashboard! before_action :authorize_read_project_security_dashboard!
def show def show
@pipeline = @project.latest_pipeline_with_legacy_security_reports @pipeline = @project.latest_pipeline_with_security_reports
&.present(current_user: current_user) &.present(current_user: current_user)
end end
......
...@@ -16,9 +16,14 @@ module EE ...@@ -16,9 +16,14 @@ module EE
has_many :vulnerabilities, source: :occurrence, through: :vulnerabilities_occurrence_pipelines, class_name: 'Vulnerabilities::Occurrence' has_many :vulnerabilities, source: :occurrence, through: :vulnerabilities_occurrence_pipelines, class_name: 'Vulnerabilities::Occurrence'
# Legacy way to fetch security reports based on job name. This has been replaced by the reports feature. # Legacy way to fetch security reports based on job name. This has been replaced by the reports feature.
scope :with_legacy_security_reports, -> { scope :with_legacy_security_reports, -> do
joins(:artifacts).where(ci_builds: { name: %w[sast dependency_scanning sast:container container_scanning dast] }) joins(:artifacts).where(ci_builds: { name: %w[sast dependency_scanning sast:container container_scanning dast] })
} end
# The new `reports:` syntax reports
scope :with_security_reports, -> do
where('EXISTS (?)', Ci::Build.select(1).latest.with_security_reports.where('ci_pipelines.id=ci_build.commit_id'))
end
# This structure describes feature levels # This structure describes feature levels
# to access the file types for given reports # to access the file types for given reports
......
...@@ -109,7 +109,8 @@ module EE ...@@ -109,7 +109,8 @@ module EE
end end
end end
def latest_pipeline_with_legacy_security_reports def latest_pipeline_with_security_reports
pipelines.newest_first(default_branch).with_security_reports.first ||
pipelines.newest_first(default_branch).with_legacy_security_reports.first pipelines.newest_first(default_branch).with_legacy_security_reports.first
end end
......
...@@ -1496,7 +1496,7 @@ describe Project do ...@@ -1496,7 +1496,7 @@ describe Project do
end end
end end
describe '#latest_pipeline_with_legacy_security_reports' do describe '#latest_pipeline_with_security_reports' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:pipeline_1) { create(:ci_pipeline_without_jobs, project: project) } let(:pipeline_1) { create(:ci_pipeline_without_jobs, project: project) }
let(:pipeline_2) { create(:ci_pipeline_without_jobs, project: project) } let(:pipeline_2) { create(:ci_pipeline_without_jobs, project: project) }
......
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