Commit 37cfbf80 authored by Victor Zagorodny's avatar Victor Zagorodny

Rename VulnerabilityFindingsFinder dependencies

parent b93016ef
...@@ -7,7 +7,7 @@ class Groups::Security::VulnerabilitiesController < Groups::ApplicationControlle ...@@ -7,7 +7,7 @@ class Groups::Security::VulnerabilitiesController < Groups::ApplicationControlle
alias_method :vulnerable, :group alias_method :vulnerable, :group
def history def history
history_count = Gitlab::Vulnerabilities::History.new(group, filter_params).vulnerabilities_counter history_count = Gitlab::Vulnerabilities::History.new(group, filter_params).findings_counter
respond_to do |format| respond_to do |format|
format.json do format.json do
......
...@@ -14,16 +14,16 @@ module Gitlab ...@@ -14,16 +14,16 @@ module Gitlab
@filters = filters @filters = filters
end end
def vulnerabilities_counter def findings_counter
return cached_vulnerability_history if use_vulnerability_cache? return cached_vulnerability_history if use_vulnerability_cache?
vulnerabilities = found_vulnerabilities.count_by_day_and_severity(HISTORY_RANGE) findings = vulnerability_findings.count_by_day_and_severity(HISTORY_RANGE)
::Vulnerabilities::HistorySerializer.new.represent(vulnerabilities) ::Vulnerabilities::HistorySerializer.new.represent(findings)
end end
private private
def found_vulnerabilities def vulnerability_findings
::Security::VulnerabilityFindingsFinder.new(group, params: filters).execute(:all) ::Security::VulnerabilityFindingsFinder.new(group, params: filters).execute(:all)
end end
......
...@@ -12,17 +12,19 @@ module Gitlab ...@@ -12,17 +12,19 @@ module Gitlab
def fetch(range, force: false) def fetch(range, force: false)
Rails.cache.fetch(cache_key, force: force, expires_in: 1.day) do Rails.cache.fetch(cache_key, force: force, expires_in: 1.day) do
vulnerabilities = ::Security::VulnerabilityFindingsFinder findings = ::Security::VulnerabilityFindingsFinder
.new(group, params: { project_id: [project_id] }) .new(group, params: { project_id: [project_id] })
.execute(:all) .execute(:all)
.count_by_day_and_severity(range) .count_by_day_and_severity(range)
::Vulnerabilities::HistorySerializer.new.represent(vulnerabilities) ::Vulnerabilities::HistorySerializer.new.represent(findings)
end end
end end
private private
def cache_key def cache_key
# TODO: rename 'vulnerabilities' to 'findings' in the cache key, but carefully
# https://gitlab.com/gitlab-org/gitlab/issues/32963
['projects', project_id, 'vulnerabilities'] ['projects', project_id, 'vulnerabilities']
end end
end end
......
...@@ -13,8 +13,8 @@ describe Gitlab::Vulnerabilities::History do ...@@ -13,8 +13,8 @@ describe Gitlab::Vulnerabilities::History do
create_vulnerabilities(2, project2, { severity: :high, report_type: :sast }) create_vulnerabilities(2, project2, { severity: :high, report_type: :sast })
end end
describe '#vulnerabilities_counter', :use_clean_rails_memory_store_caching do describe '#findings_counter', :use_clean_rails_memory_store_caching do
subject(:counter) { described_class.new(group, filters).vulnerabilities_counter } subject(:counter) { described_class.new(group, filters).findings_counter }
context 'feature disabled' do context 'feature disabled' do
before do before do
......
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