debian-mirror-gitlab/lib/gitlab/ci/reports/reports_comparer.rb

65 lines
1.3 KiB
Ruby
Raw Normal View History

2021-02-22 17:27:13 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
module Reports
class ReportsComparer
include Gitlab::Utils::StrongMemoize
STATUS_SUCCESS = 'success'
STATUS_FAILED = 'failed'
2021-04-17 20:07:23 +05:30
STATUS_NOT_FOUND = 'not_found'
2021-02-22 17:27:13 +05:30
attr_reader :base_report, :head_report
def initialize(base_report, head_report)
@base_report = base_report
@head_report = head_report
end
def status
2021-04-17 20:07:23 +05:30
if base_report.nil? || head_report.nil?
STATUS_NOT_FOUND
elsif success?
STATUS_SUCCESS
else
STATUS_FAILED
end
2021-02-22 17:27:13 +05:30
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
2021-04-17 20:07:23 +05:30
def not_found?
status == STATUS_NOT_FOUND
end
2021-02-22 17:27:13 +05:30
end
end
end
end