1# frozen_string_literal: true 2 3module Ci 4 # TODO: a couple of points with this approach: 5 # + reuses existing architecture and reactive caching 6 # - it's not a report comparison and some comparing features must be turned off. 7 # see CompareReportsBaseService for more notes. 8 # issue: https://gitlab.com/gitlab-org/gitlab/issues/34224 9 class GenerateCodequalityMrDiffReportService < CompareReportsBaseService 10 def execute(base_pipeline, head_pipeline) 11 merge_request = MergeRequest.find_by_id(params[:id]) 12 { 13 status: :parsed, 14 key: key(base_pipeline, head_pipeline), 15 data: head_pipeline.pipeline_artifacts.find_by_file_type(:code_quality_mr_diff).present.for_files(merge_request) 16 } 17 rescue StandardError => e 18 Gitlab::ErrorTracking.track_exception(e, project_id: project.id) 19 { 20 status: :error, 21 key: key(base_pipeline, head_pipeline), 22 status_reason: _('An error occurred while fetching codequality mr diff reports.') 23 } 24 end 25 26 def latest?(base_pipeline, head_pipeline, data) 27 data&.fetch(:key, nil) == key(base_pipeline, head_pipeline) 28 end 29 end 30end 31