Class: Katello::ContentUnitIndexer::RepoAssociationTracker
- Inherits:
-
Object
- Object
- Katello::ContentUnitIndexer::RepoAssociationTracker
- Defined in:
- app/services/katello/content_unit_indexer.rb
Instance Method Summary collapse
- #db_values ⇒ Object
-
#initialize(content_type, service_class, repository) ⇒ RepoAssociationTracker
constructor
A new instance of RepoAssociationTracker.
- #pulp_href_association_name ⇒ Object
- #pulp_prn_association_name ⇒ Object
-
#push(unit) ⇒ Object
pulp_href is only provided if we’re storing a different ‘pulp_id’ on the repo association.
- #unit_ids ⇒ Object
Constructor Details
#initialize(content_type, service_class, repository) ⇒ RepoAssociationTracker
Returns a new instance of RepoAssociationTracker.
91 92 93 94 95 96 |
# File 'app/services/katello/content_unit_indexer.rb', line 91 def initialize(content_type, service_class, repository) @values = {} @content_type = content_type @repository = repository @service_class = service_class end |
Instance Method Details
#db_values ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'app/services/katello/content_unit_indexer.rb', line 115 def db_values return @final_values if @final_values @final_value = [] @final_values = ::Katello::ContentUnitIndexer.pulp_id_to_id_map(@content_type, @values.keys).map do |pulp_id, katello_id| #:repository_id => X, :erratum_id => y row = {:repository_id => @repository.id, @content_type.model_class.unit_id_field => katello_id} if pulp_href_association_name row[pulp_href_association_name] = @values[pulp_id][:href] row[pulp_prn_association_name] = @values[pulp_id][:prn] if pulp_prn_association_name end row end ContentUnitIndexer.(@content_type.model_class, @final_values) @final_values end |
#pulp_href_association_name ⇒ Object
132 133 134 |
# File 'app/services/katello/content_unit_indexer.rb', line 132 def pulp_href_association_name 'erratum_pulp3_href' if @content_type.label == 'erratum' end |
#pulp_prn_association_name ⇒ Object
136 137 138 |
# File 'app/services/katello/content_unit_indexer.rb', line 136 def pulp_prn_association_name 'erratum_prn' if @content_type.label == 'erratum' end |
#push(unit) ⇒ Object
pulp_href is only provided if we’re storing a different ‘pulp_id’ on the repo association
103 104 105 106 107 108 109 110 111 112 113 |
# File 'app/services/katello/content_unit_indexer.rb', line 103 def push(unit) if @service_class.backend_unit_identifier pulp_href = unit.dig(@service_class.backend_unit_identifier) pulp_prn = unit['prn'] else pulp_href = nil pulp_prn = nil end unit_id = unit[@service_class.unit_identifier] @values[unit_id] = { href: pulp_href, prn: pulp_prn } end |
#unit_ids ⇒ Object
98 99 100 |
# File 'app/services/katello/content_unit_indexer.rb', line 98 def unit_ids db_values.map { |row| row[@content_type.model_class.unit_id_field] } end |