lib/topological_inventory/schema/default.rb
# This method is updating one by one using ActiveRecord
This method is updating one by one using ActiveRecord
This method is updating one by one using ActiveRecord
def service_instance_tasks_update_by_activerecord(tasks_collection, source, svc_instances_source_ref)
        service_instances = ServiceInstance.where(:source_id => source.id, :source_ref => svc_instances_source_ref)
        tasks_by_source_ref = Task.where(:state => 'running', :target_type => 'ServiceInstance', :source_id => source.id, :target_source_ref => service_instances.pluck(:source_ref)).index_by(&:target_source_ref)
        service_instances.select(:id, :archived_at, :external_url, :source_ref, :extra).find_in_batches do |group|
          ActiveRecord::Base.transaction do
            group.each do |svc_instance|
              next if (task = tasks_by_source_ref[svc_instance.source_ref]).nil?
              values = task_update_values(svc_instance.id, svc_instance.source_ref, svc_instance.external_url, svc_instance.extra['status'], svc_instance.extra['artifacts'], svc_instance.extra['task_status'], svc_instance.extra['finished'], svc_instance.archived_at, source.id)
              task.update(values)
              tasks_collection.updated_records << values.merge(:id => task.id, :forwardable_headers => task.forwardable_headers)
            end
          end
        end
      end
def service_instance_tasks_update_by_activerecord ( tasks_collection , source , svc_instances_source_ref ) service_instances = ServiceInstance . where ( :source_id => source . id , :source_ref => svc_instances_source_ref ) tasks_by_source_ref = Task . where ( :state => 'running' , :target_type => 'ServiceInstance' , :source_id => source . id , :target_source_ref => service_instances . pluck ( :source_ref ) ) . index_by ( & :target_source_ref ) service_instances . select ( :id , :archived_at , :external_url , :source_ref , :extra ) . find_in_batches do | group | ActiveRecord :: Base . transaction do group . each do | svc_instance | next if ( task = tasks_by_source_ref [ svc_instance . source_ref ] ) . nil? values = task_update_values ( svc_instance . id , svc_instance . source_ref , svc_instance . external_url , svc_instance . extra [ 'status' ] , svc_instance . extra [ 'artifacts' ] , svc_instance . extra [ 'task_status' ] , svc_instance . extra [ 'finished' ] , svc_instance . archived_at , source . id ) task . update ( values ) tasks_collection . updated_records << values . merge ( :id => task . id , :forwardable_headers => task . forwardable_headers ) end end end end
This method is updating one by one using ActiveRecord
This method is updating one by one using ActiveRecord
# 1) Updating Task # 2) Saving to updated records (will be published in Kafka) # - see topological_inventory-persister:Workflow.send_task_updates_to_queue!
tasks_collection
source
svc_instances_source_ref