From 945030c0bd23ee84a902a30b97aab7ce882361d7 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Wed, 9 Aug 2017 14:27:51 +0200 Subject: [PATCH 1/2] Use the whole batch for storing updated records Use the whole batch for storing updated records --- .../save_collection/saver/concurrent_safe_batch.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/manager_refresh/save_collection/saver/concurrent_safe_batch.rb b/app/models/manager_refresh/save_collection/saver/concurrent_safe_batch.rb index aec05a35962..66e9fe7a64b 100644 --- a/app/models/manager_refresh/save_collection/saver/concurrent_safe_batch.rb +++ b/app/models/manager_refresh/save_collection/saver/concurrent_safe_batch.rb @@ -125,7 +125,6 @@ def update_or_destroy_records!(records_batch_iterator, inventory_objects_index, hash end assign_attributes_for_update!(hash_for_update, update_time) - inventory_collection.store_updated_records([{:id => primary_key_value}]) hash_for_update[:id] = primary_key_value hashes_for_update << hash_for_update @@ -185,6 +184,7 @@ def destroy_records!(records) def update_records!(all_attribute_keys, hashes) return if hashes.blank? + inventory_collection.store_updated_records(hashes) query = build_update_query(all_attribute_keys, hashes) get_connection.execute(query) end From 54eb02c0833eccbc4eff7b60ffb2daa8525fc6a8 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Wed, 9 Aug 2017 14:29:30 +0200 Subject: [PATCH 2/2] Store updated records as a part of batch disconnect Store updated records as a part of batch disconnect --- .../save_collection/saver/concurrent_safe_batch.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/manager_refresh/save_collection/saver/concurrent_safe_batch.rb b/app/models/manager_refresh/save_collection/saver/concurrent_safe_batch.rb index 66e9fe7a64b..5473d866e0b 100644 --- a/app/models/manager_refresh/save_collection/saver/concurrent_safe_batch.rb +++ b/app/models/manager_refresh/save_collection/saver/concurrent_safe_batch.rb @@ -162,7 +162,7 @@ def destroy_records!(records) rails_delete = %i(destroy delete).include?(inventory_collection.delete_method) if !rails_delete && inventory_collection.model_class.respond_to?(inventory_collection.delete_method) # We have custom delete method defined on a class, that means it supports batch destroy - # TODO(lsmola) store deleted records to IC + inventory_collection.store_deleted_records(records.map { |x| {:id => record_key(x, primary_key)} }) inventory_collection.model_class.public_send(inventory_collection.delete_method, records.map { |x| record_key(x, primary_key) }) else # We have either standard :destroy and :delete rails method, or custom instance level delete method