Welcome to mirror list, hosted at ThFree Co, Russian Federation.

reports_comparer.rb « reports « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 16a7f6478b7f328b05a0c3182d9127656e5ff95f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# frozen_string_literal: true

module Gitlab
  module Ci
    module Reports
      class ReportsComparer
        include Gitlab::Utils::StrongMemoize

        STATUS_SUCCESS = 'success'
        STATUS_FAILED = 'failed'
        STATUS_NOT_FOUND = 'not_found'

        attr_reader :base_report, :head_report

        def initialize(base_report, head_report)
          @base_report = base_report
          @head_report = head_report
        end

        def status
          if base_report.nil? || head_report.nil?
            STATUS_NOT_FOUND
          elsif success?
            STATUS_SUCCESS
          else
            STATUS_FAILED
          end
        end

        def success?
          raise NotImplementedError
        end

        def existing_errors
          raise NotImplementedError
        end

        def new_errors
          raise NotImplementedError
        end

        def resolved_errors
          raise NotImplementedError
        end

        def errors_count
          raise NotImplementedError
        end

        def resolved_count
          resolved_errors.size
        end

        def total_count
          existing_errors.size + new_errors.size
        end

        def not_found?
          status == STATUS_NOT_FOUND
        end
      end
    end
  end
end