Sha256: 99eae938aba6abc8fa3962b6a2e5736af8a28536832d96da3bed214ed5822069

Contents?: true

Size: 1.78 KB

Versions: 55

Compression:

Stored size: 1.78 KB

Contents

module Actions
  module Pulp3
    module Repository
      module Presenters
        class ContentUnitPresenter < AbstractSyncPresenter
          def progress
            total_units == 0 ? 0.1 : finished_units.to_f / total_units
          end

          private

          def humanized_details
            ret = []
            ret << _("Cancelled.") if cancelled?
            ret << _("Total steps: ") + "#{finished_units}/#{total_units}"
            ret << "--------------------------------"
            progress_reports = sync_task.try(:[], 'progress_reports') || []
            progress_reports = progress_reports.sort_by { |pr| pr.try(:[], 'message') }
            progress_reports.each do |pr|
              done = pr.try(:[], 'done')
              total = pr.try(:[], 'total') || pr.try(:[], 'done')
              unless done.nil? || total.nil?
                ret << _(pr.try(:[], 'message') + ": #{done}/#{total}")
              end
            end

            ret.join("\n")
          end

          def total_units
            total_unit = 0
            progress_reports = sync_task.try(:[], 'progress_reports') || []
            progress_reports.each do |pr|
              total = pr.try(:[], 'total')
              total = pr.try(:[], 'done') if total.nil?
              unless total.nil?
                total_unit += total.to_i
              end
            end
            total_unit
          end

          def finished_units
            finished_unit = 0
            progress_reports = sync_task.try(:[], 'progress_reports') || []
            progress_reports.each do |pr|
              done = pr.try(:[], 'done')
              unless done.nil?
                finished_unit += done.to_i
              end
            end
            finished_unit
          end
        end
      end
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
katello-4.1.0.rc2.2 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-4.1.0.rc2.1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-4.0.1.1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.18.3 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-4.1.0.rc2 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-4.0.1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-4.1.0.rc1.1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-4.1.0.rc1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-4.0.0 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-4.0.0.rc3.1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-4.0.0.rc3 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.18.2.1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.18.2 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.17.3 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-4.0.0.rc2 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.18.1.1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.17.2 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-4.0.0.rc1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.18.1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.18.0 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb