Commit 58420132 authored by Michał Zając's avatar Michał Zając

Rename occurrence_key to finding_key

parent 96278cf9
...@@ -76,7 +76,7 @@ module Vulnerabilities ...@@ -76,7 +76,7 @@ module Vulnerabilities
comment.present? && comment_author.present? comment.present? && comment_author.present?
end end
def occurrence_key def finding_key
{ {
project_id: project_id, project_id: project_id,
category: category, category: category,
......
...@@ -194,10 +194,10 @@ module Vulnerabilities ...@@ -194,10 +194,10 @@ module Vulnerabilities
end end
def load_feedback def load_feedback
BatchLoader.for(occurrence_key).batch(replace_methods: false) do |occurrence_keys, loader| BatchLoader.for(finding_key).batch(replace_methods: false) do |finding_keys, loader|
project_ids = occurrence_keys.map { |key| key[:project_id] } project_ids = finding_keys.map { |key| key[:project_id] }
categories = occurrence_keys.map { |key| key[:category] } categories = finding_keys.map { |key| key[:category] }
fingerprints = occurrence_keys.map { |key| key[:project_fingerprint] } fingerprints = finding_keys.map { |key| key[:project_fingerprint] }
feedback = Vulnerabilities::Feedback.all_preloaded.where( feedback = Vulnerabilities::Feedback.all_preloaded.where(
project_id: project_ids.uniq, project_id: project_ids.uniq,
...@@ -205,10 +205,10 @@ module Vulnerabilities ...@@ -205,10 +205,10 @@ module Vulnerabilities
project_fingerprint: fingerprints.uniq project_fingerprint: fingerprints.uniq
).to_a ).to_a
occurrence_keys.each do |occurrence_key| finding_keys.each do |finding_key|
loader.call( loader.call(
occurrence_key, finding_key,
feedback.select { |f| occurrence_key == f.occurrence_key } feedback.select { |f| finding_key == f.finding_key }
) )
end end
end end
...@@ -311,7 +311,7 @@ module Vulnerabilities ...@@ -311,7 +311,7 @@ module Vulnerabilities
private private
def occurrence_key def finding_key
{ {
project_id: project_id, project_id: project_id,
category: report_type, category: report_type,
......
...@@ -157,7 +157,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do ...@@ -157,7 +157,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do
let(:finding) { build(:ci_reports_security_finding, severity: nil) } let(:finding) { build(:ci_reports_security_finding, severity: nil) }
before do before do
subject.add_finding(finding) subject.add_finding(finding)
end end
it { expect(subject.unsafe_severity?).to be(false) } it { expect(subject.unsafe_severity?).to be(false) }
...@@ -168,7 +168,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do ...@@ -168,7 +168,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do
let(:finding) { build(:ci_reports_security_finding, severity: '') } let(:finding) { build(:ci_reports_security_finding, severity: '') }
before do before do
subject.add_finding(finding) subject.add_finding(finding)
end end
it { expect(subject.unsafe_severity?).to be(false) } it { expect(subject.unsafe_severity?).to be(false) }
......
...@@ -228,7 +228,7 @@ RSpec.describe Vulnerabilities::Feedback do ...@@ -228,7 +228,7 @@ RSpec.describe Vulnerabilities::Feedback do
let(:expected_occurrence_key) { { project_id: project_id, category: category, project_fingerprint: project_fingerprint } } let(:expected_occurrence_key) { { project_id: project_id, category: category, project_fingerprint: project_fingerprint } }
let(:feedback) { build(:vulnerability_feedback, expected_occurrence_key) } let(:feedback) { build(:vulnerability_feedback, expected_occurrence_key) }
subject { feedback.occurrence_key } subject { feedback.finding_key }
it { is_expected.to eq(expected_occurrence_key) } it { is_expected.to eq(expected_occurrence_key) }
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