Commit eaf2607e authored by Giorgenes Gelatti's avatar Giorgenes Gelatti

Improve Vulnerability Findinds code quality

parent 57aa6197
......@@ -3,15 +3,20 @@
module API
class VulnerabilityFindings < Grape::API
include PaginationParams
include ::Gitlab::Utils::StrongMemoize
helpers do
def vulnerability_occurrences_by(params)
pipeline = if params[:pipeline_id]
user_project.all_pipelines.find_by(id: params[:pipeline_id]) # rubocop:disable CodeReuse/ActiveRecord
def pipeline
strong_memoize(:pipeline) do
if params[:pipeline_id]
user_project.all_pipelines.for_id(params[:pipeline_id]).first
else
user_project.latest_pipeline_with_security_reports
end
end
end
def vulnerability_occurrences_by(params)
return [] unless pipeline
aggregated_report = Security::PipelineVulnerabilitiesFinder.new(pipeline: pipeline, params: params).execute
......
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