From 805199880a2487975b4c3d9cf17f5a414ef82a03 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 6 Jun 2017 14:09:50 +0200 Subject: [PATCH] Improved mem usage. --- app/models/concerns/has_search_index_backend.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/has_search_index_backend.rb b/app/models/concerns/has_search_index_backend.rb index 4ab81a4ab..42b14a822 100644 --- a/app/models/concerns/has_search_index_backend.rb +++ b/app/models/concerns/has_search_index_backend.rb @@ -123,7 +123,9 @@ reload search index with full data def search_index_reload tolerance = 5 tolerance_count = 0 - all.order('created_at DESC').each { |item| + ids = all.order('created_at DESC').pluck(:id) + ids.each { |item_id| + item = find(item_id) next if item.ignore_search_indexing?(:destroy) begin item.search_index_update_backend