Commit 12baf134 authored by Victor Zagorodny's avatar Victor Zagorodny

Rename VulnerabilityFindingsFinder dependencies

parent d3529fd2
......@@ -7,7 +7,7 @@ class Groups::Security::VulnerabilitiesController < Groups::ApplicationControlle
alias_method :vulnerable, :group
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|
format.json do
......
......@@ -14,16 +14,16 @@ module Gitlab
@filters = filters
end
def vulnerabilities_counter
def findings_counter
return cached_vulnerability_history if use_vulnerability_cache?
vulnerabilities = found_vulnerabilities.count_by_day_and_severity(HISTORY_RANGE)
::Vulnerabilities::HistorySerializer.new.represent(vulnerabilities)
findings = vulnerability_findings.count_by_day_and_severity(HISTORY_RANGE)
::Vulnerabilities::HistorySerializer.new.represent(findings)
end
private
def found_vulnerabilities
def vulnerability_findings
::Security::VulnerabilityFindingsFinder.new(group, params: filters).execute(:all)
end
......
......@@ -12,17 +12,19 @@ module Gitlab
def fetch(range, force: false)
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] })
.execute(:all)
.count_by_day_and_severity(range)
::Vulnerabilities::HistorySerializer.new.represent(vulnerabilities)
::Vulnerabilities::HistorySerializer.new.represent(findings)
end
end
private
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']
end
end
......
......@@ -13,8 +13,8 @@ describe Gitlab::Vulnerabilities::History do
create_vulnerabilities(2, project2, { severity: :high, report_type: :sast })
end
describe '#vulnerabilities_counter', :use_clean_rails_memory_store_caching do
subject(:counter) { described_class.new(group, filters).vulnerabilities_counter }
describe '#findings_counter', :use_clean_rails_memory_store_caching do
subject(:counter) { described_class.new(group, filters).findings_counter }
context 'feature disabled' 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