Commit d5fec7ff authored by James Johnson's avatar James Johnson

Remove join with Vulnerability model

parent 9062eda8
......@@ -59,9 +59,8 @@ module Security
def vulnerabilities_by_finding_fingerprint(report_type, report)
Vulnerabilities::Finding
.by_project_fingerprints(report.findings.map(&:project_fingerprint))
.where(
project: pipeline.project,
report_type: report_type)
.by_projects(pipeline.project)
.by_report_types(report_type)
.select(:vulnerability_id, :project_fingerprint)
.each_with_object({}) do |finding, hash|
hash[finding.project_fingerprint] = finding.vulnerability_id
......
......@@ -97,13 +97,13 @@ RSpec.describe Security::PipelineVulnerabilitiesFinder do
project_fingerprint: report_finding.project_fingerprint)
end
# there's something being cached... need to run this once to get rid of that
# Need to warm the cache
described_class.new(pipeline: pipeline, params: { report_type: %w[dependency_scanning] }).execute
expect {
described_class.new(pipeline: pipeline, params: { report_type: %w[dependency_scanning] }).execute
}.to issue_same_number_of_queries_as {
expect do
described_class.new(pipeline: pipeline, params: { report_type: %w[sast] }).execute
end.to issue_same_number_of_queries_as {
described_class.new(pipeline: pipeline, params: { report_type: %w[dependency_scanning] }).execute
}
end
end
......
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