Class: Actions::Katello::Agent::DispatchHistoryPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/lib/actions/katello/agent/dispatch_history_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(dispatch_history, action_type) ⇒ DispatchHistoryPresenter

Returns a new instance of DispatchHistoryPresenter.



5
6
7
8
# File 'app/lib/actions/katello/agent/dispatch_history_presenter.rb', line 5

def initialize(dispatch_history, action_type)
  @result = dispatch_history&.result&.with_indifferent_access
  @action_type = action_type
end

Instance Method Details

#error_messagesObject



25
26
27
28
29
30
31
32
33
# File 'app/lib/actions/katello/agent/dispatch_history_presenter.rb', line 25

def error_messages
  messages = []
  @result.each_value do |result|
    if !result[:succeeded] && result.dig(:details, :message)
      messages << result[:details][:message]
    end
  end
  messages
end

#humanized_outputObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/lib/actions/katello/agent/dispatch_history_presenter.rb', line 10

def humanized_output
  return if @result.empty?

  result = package_result

  if result[:message]
    result[:message]
  elsif result[:packages].any?
    packages = result[:packages].map { |package| package[:qname] }
    packages.sort.join("\n")
  else
    humanized_no_package
  end
end