Sha256: e5552cc8110f3678c732870765668dcdc84e29d374dd3c6e2928d9a28aad20de

Contents?: true

Size: 538 Bytes

Versions: 8

Compression:

Stored size: 538 Bytes

Contents

module ForemanStatistics
  module Statistics
    class CountPuppetClasses < Base
      def initialize(options = {})
        super(options)
        if id.empty?
          raise(ArgumentError, 'Must provide an :id or :count_by option')
        end
      end

      def calculate
        Puppetclass.authorized(:view_puppetclasses).map do |pc|
          count = pc.hosts_count
          next if count.zero?
          {
            :label => pc.to_label,
            :data => count
          }
        end.compact
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
foreman_statistics-1.2.0 app/services/foreman_statistics/statistics/count_puppet_classes.rb
foreman_statistics-1.1.1 app/services/foreman_statistics/statistics/count_puppet_classes.rb
foreman_statistics-1.1.0 app/services/foreman_statistics/statistics/count_puppet_classes.rb
foreman_statistics-1.0.0 app/services/foreman_statistics/statistics/count_puppet_classes.rb
foreman_statistics-0.1.3 app/services/foreman_statistics/statistics/count_puppet_classes.rb
foreman_statistics-0.1.2 app/services/foreman_statistics/statistics/count_puppet_classes.rb
foreman_statistics-0.1.1 app/services/foreman_statistics/statistics/count_puppet_classes.rb
foreman_statistics-0.1.0 app/services/foreman_statistics/statistics/count_puppet_classes.rb