Sha256: 8f1e54ac1a6e54d8f273a01f45ae6b2f74db84e3d5cf1d7b3da911b1a58bfab9

Contents?: true

Size: 1.7 KB

Versions: 12

Compression:

Stored size: 1.7 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 tasks: ") + ": #{finished_units}/#{total_units}"
            ret << "--------------------------------"
            progress_reports = sync_task.try(:[], 'progress_reports') || []
            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

12 entries across 12 versions & 1 rubygems

Version Path
katello-3.14.1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.13.4 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.14.0 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.13.3 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.14.0.rc2 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.13.2 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.14.0.rc1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.13.1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.13.0 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.13.0.rc2.1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.13.0.rc2 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb
katello-3.13.0.rc1 app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb