From eb47a0c2c8133446c167cf3998a5ef92c0fa8109 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 3 Feb 2014 19:27:49 +0100 Subject: [PATCH] Moved to background jobs for search indexing. --- app/models/application_model.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 80d08e0b8..41f1b8358 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -488,7 +488,10 @@ update search index, if configured - will be executed automatically def search_index_update return if !self.class.search_index_support_config - search_index_update_backend + + # start background job to transfer data to search index + return if !SearchIndexBackend.enabled? + Delayed::Job.enqueue( ApplicationModel::Job.new( self.class.to_s, self.id ) ) end =begin @@ -783,4 +786,11 @@ destory object dependencies, will be executed automatically def destroy_dependencies end + # perform background job + class ApplicationModel::Job < Struct.new( :object, :o_id ) + def perform + Object.const_get(object).find(o_id).search_index_update_backend + end + end + end