Class: Actions::Katello::Repository::IndexContent

Inherits:
EntryAction
  • Object
show all
Defined in:
app/lib/actions/katello/repository/index_content.rb

Instance Method Summary collapse

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/lib/actions/katello/repository/index_content.rb', line 12

def run
  source_repository = ::Katello::Repository.find(input[:source_repository_id]) if input[:source_repository_id]
  repo = ::Katello::Repository.find(input[:id])

  initial_counts = {}
  repo.repository_type.primary_content_types.each do |content_type|
    initial_counts[content_type.label] = content_type.model_class.in_repositories(repo).count
  end

  if input[:force_index] || (repo.last_contents_changed >= repo.last_indexed)
    repo.index_content(source_repository: source_repository, full_index: input[:full_index].present?)
    repo.update(:last_indexed => DateTime.now)
  else
    output[:index_skipped] = true
  end

  output[:new_content] = {}
  repo.repository_type.primary_content_types.each do |content_type|
    new_count = content_type.model_class.in_repositories(repo).count
    output[:new_content][content_type.label] = new_count - initial_counts[content_type.label]
  end
end