Class: Ci::CompareReportsBaseService

Inherits:
BaseService show all
Defined in:
app/services/ci/compare_reports_base_service.rb

Overview

TODO: when using this class with exposed artifacts we see that there are 2 responsibilities:

  1. reactive caching interface (same in all cases)

  2. data generator (report comparison in most of the case but not always)

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?

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
25
26
27
28
29
30
# File 'app/services/ci/compare_reports_base_service.rb', line 10

def execute(base_pipeline, head_pipeline)
  return parsing_payload(base_pipeline, head_pipeline) if base_pipeline&.running?

  base_report = get_report(base_pipeline)
  head_report = get_report(head_pipeline)
  comparer = build_comparer(base_report, head_report)

  {
    status: :parsed,
    key: key(base_pipeline, head_pipeline),
    data: serializer_class
      .new(**serializer_params)
      .represent(comparer).as_json
  }
rescue Gitlab::Ci::Parsers::ParserError => e
  {
    status: :error,
    key: key(base_pipeline, head_pipeline),
    status_reason: e.message
  }
end

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

Returns:

  • (Boolean)


32
33
34
# File 'app/services/ci/compare_reports_base_service.rb', line 32

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