Class: Katello::Pulp::ContentCountsCalculator

Inherits:
Object
  • Object
show all
Defined in:
app/services/katello/pulp/content_counts_calculator.rb

Instance Method Summary collapse

Constructor Details

#initialize(repos) ⇒ ContentCountsCalculator

Returns a new instance of ContentCountsCalculator.



4
5
6
# File 'app/services/katello/pulp/content_counts_calculator.rb', line 4

def initialize(repos)
  @repos = repos
end

Instance Method Details

#calculateObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/services/katello/pulp/content_counts_calculator.rb', line 8

def calculate
  counts = {
    :yum_repositories => 0,
    :packages => 0,
    :package_groups => 0,
    :errata => 0,
    :puppet_repositories => 0,
    :puppet_modules => 0,
    :docker_repositories => 0,
    :docker_images => 0
  }

  @repos.each do |repo|
    case
    when repo_type?(repo, 'rpm')
      counts[:yum_repositories] += 1
      counts[:packages] += get_unit_count(repo, 'rpm')
      counts[:package_groups] += get_unit_count(repo, 'package_group')
      counts[:errata] += get_unit_count(repo, 'erratum')
    when repo_type?(repo, 'docker')
      counts[:docker_repositories] += 1
      counts[:docker_images] += get_unit_count(repo, 'docker_image')
    when repo_type?(repo, 'puppet')
      counts[:puppet_repositories] += 1
      counts[:puppet_modules] += get_unit_count(repo, 'puppet_module')
    end
  end

  counts
end