Class: Katello::SyncStatusPresenter

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::DateHelper, TranslationHelper
Defined in:
app/presenters/katello/sync_status_presenter.rb

Constant Summary collapse

STATUS_VALUES =
{
  :stopped      => _("Syncing Complete."),
  :error        => _("Sync Incomplete"),
  :never_synced => _("Never Synced"),
  :running      => _("Running"),
  :canceled     => _("Canceled"),
  :paused       => _("Paused")
}.with_indifferent_access

Instance Method Summary collapse

Methods included from TranslationHelper

#month, #months, #relative_time_in_words

Constructor Details

#initialize(repo, task) ⇒ SyncStatusPresenter

Returns a new instance of SyncStatusPresenter.



14
15
16
17
# File 'app/presenters/katello/sync_status_presenter.rb', line 14

def initialize(repo, task)
  @repo = repo
  @task = task
end

Instance Method Details

#sync_progressObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/presenters/katello/sync_status_presenter.rb', line 19

def sync_progress
  return {:state => nil} unless @repo
  return empty_task(@repo) unless @task
  {
    :id             => @repo.id,
    :product_id     => @repo.product.id,
    :progress       => {:progress => @task.progress * 100},
    :sync_id        => @task.id,
    :state          => format_state(@task),
    :raw_state      => raw_state(@task),
    :start_time     => format_date(@task.started_at),
    :finish_time    => format_date(@task.ended_at),
    :duration       => format_duration(@task.ended_at, @task.started_at),
    :display_size   => @task.humanized[:output],
    :size           => @task.humanized[:output],
    :is_running     => @task.pending && @task.state != 'paused',
    :error_details  => @task.errors
  }
end