Commit d5fec7ff authored by James Johnson's avatar James Johnson

Remove join with Vulnerability model

parent 9062eda8
...@@ -59,9 +59,8 @@ module Security ...@@ -59,9 +59,8 @@ module Security
def vulnerabilities_by_finding_fingerprint(report_type, report) def vulnerabilities_by_finding_fingerprint(report_type, report)
Vulnerabilities::Finding Vulnerabilities::Finding
.by_project_fingerprints(report.findings.map(&:project_fingerprint)) .by_project_fingerprints(report.findings.map(&:project_fingerprint))
.where( .by_projects(pipeline.project)
project: pipeline.project, .by_report_types(report_type)
report_type: report_type)
.select(:vulnerability_id, :project_fingerprint) .select(:vulnerability_id, :project_fingerprint)
.each_with_object({}) do |finding, hash| .each_with_object({}) do |finding, hash|
hash[finding.project_fingerprint] = finding.vulnerability_id hash[finding.project_fingerprint] = finding.vulnerability_id
......
...@@ -97,13 +97,13 @@ RSpec.describe Security::PipelineVulnerabilitiesFinder do ...@@ -97,13 +97,13 @@ RSpec.describe Security::PipelineVulnerabilitiesFinder do
project_fingerprint: report_finding.project_fingerprint) project_fingerprint: report_finding.project_fingerprint)
end 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 described_class.new(pipeline: pipeline, params: { report_type: %w[dependency_scanning] }).execute
expect { expect do
described_class.new(pipeline: pipeline, params: { report_type: %w[dependency_scanning] }).execute
}.to issue_same_number_of_queries_as {
described_class.new(pipeline: pipeline, params: { report_type: %w[sast] }).execute 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
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