lib/topological_inventory/orchestrator/targeted_update/api_load_has_one.rb
def api_load_has_one_group_targets(dest_model, src_model, targets)
          dest_ids, dest_targets = {}, {}

          targets.each do |target|
            next if target[dest_model].present? # Was loaded previously
            next if target[src_model].nil? # Could be destroy event when Source was deleted before

            target_data = target[src_model]
            dest_id     = target_data['id'].to_i

            dest_ids[target_data['tenant']] ||= []
            dest_ids[target_data['tenant']] << dest_id

            dest_targets[dest_id] ||= []
            dest_targets[dest_id] << target
          end

          [dest_ids, dest_targets]
        end
# API request
#
# Loading has_one associations (API calls reduced to one request/tenant)
# Sources db have defined has_many, but practically has_one is used (i.e. Source has_one Endpoint)
API request
Loading has_one associations (API calls reduced to one request/tenant)
Sources db have defined has_many, but practically has_one is used
API request Loading has_one associations ( API calls reduced to one request / tenant ) Sources db have defined has_many but practically has_one is used
def api_load_has_one_group_targets(dest_model, src_model, targets)
          dest_ids, dest_targets = {}, {}
          targets.each do |target|
            next if target[dest_model].present? 
            next if target[src_model].nil? 
            target_data = target[src_model]
            dest_id     = target_data['id'].to_i
            dest_ids[target_data['tenant']] ||= []
            dest_ids[target_data['tenant']] << dest_id
            dest_targets[dest_id] ||= []
            dest_targets[dest_id] << target
          end
          [dest_ids, dest_targets]
        end
def api_load_has_one_group_targets ( dest_model , src_model , targets ) dest_ids , dest_targets = { } , { } targets . each do | target | next if target [ dest_model ] . present? next if target [ src_model ] . nil? target_data = target [ src_model ] dest_id = target_data [ 'id' ] . to_i dest_ids [ target_data [ 'tenant' ] ] ||= [ ] dest_ids [ target_data [ 'tenant' ] ] << dest_id dest_targets [ dest_id ] ||= [ ] dest_targets [ dest_id ] << target end [ dest_ids , dest_targets ] end
API request
Loading has_one associations (API calls reduced to one request/tenant)
Sources db have defined has_many, but practically has_one is used (i.e.
API request Loading has_one associations ( API calls reduced to one request / tenant ) Sources db have defined has_many but practically has_one is used ( i . e .
# Was loaded previously # Could be destroy event when Source was deleted before
dest_model
src_model
targets