Commit b283c32a authored by Jarka Košanová's avatar Jarka Košanová

Merge branch 'improve-vulnerability-findinds-quality' into 'master'

Improve Vulnerability Findings code quality

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