Class: Ci::GenerateCodequalityMrDiffReportService

Inherits:
CompareReportsBaseService show all
Defined in:
app/services/ci/generate_codequality_mr_diff_report_service.rb

Overview

TODO: a couple of points with this approach: + reuses existing architecture and reactive caching

  • it’s not a report comparison and some comparing features must be turned off.

see CompareReportsBaseService for more notes. issue: gitlab.com/gitlab-org/gitlab/issues/34224

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#execute(base_pipeline, head_pipeline) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/ci/generate_codequality_mr_diff_report_service.rb', line 10

def execute(base_pipeline, head_pipeline)
  merge_request = MergeRequest.find_by_id(params[:id])
  {
    status: :parsed,
    key: key(base_pipeline, head_pipeline),
    data: head_pipeline.pipeline_artifacts.find_by_file_type(:code_quality_mr_diff).present.for_files(merge_request)
  }
rescue StandardError => e
  Gitlab::ErrorTracking.track_exception(e, project_id: project.id)
  {
    status: :error,
    key: key(base_pipeline, head_pipeline),
    status_reason: _('An error occurred while fetching codequality mr diff reports.')
  }
end

#latest?(base_pipeline, head_pipeline, data) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/services/ci/generate_codequality_mr_diff_report_service.rb', line 26

def latest?(base_pipeline, head_pipeline, data)
  data&.fetch(:key, nil) == key(base_pipeline, head_pipeline)
end