|
@@ -4,9 +4,7 @@ module HasSearchIndexBackend
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
included do
|
|
|
- after_create :search_index_update
|
|
|
- after_update :search_index_update
|
|
|
- after_touch :search_index_update_touch
|
|
|
+ after_commit :search_index_update, if: :persisted?
|
|
|
after_destroy :search_index_destroy
|
|
|
end
|
|
|
|
|
@@ -25,32 +23,13 @@ update search index, if configured - will be executed automatically
|
|
|
# start background job to transfer data to search index
|
|
|
return true if !SearchIndexBackend.enabled?
|
|
|
|
|
|
- return true if saved_changes.blank?
|
|
|
+ return true if previous_changes.blank?
|
|
|
|
|
|
SearchIndexJob.perform_later(self.class.to_s, id)
|
|
|
SearchIndexAssociationsJob.perform_later(self.class.to_s, id)
|
|
|
true
|
|
|
end
|
|
|
|
|
|
-=begin
|
|
|
-
|
|
|
-update search index, if configured - will be executed automatically
|
|
|
-
|
|
|
- model = Model.find(123)
|
|
|
- model.search_index_update_touch
|
|
|
-
|
|
|
-=end
|
|
|
-
|
|
|
- def search_index_update_touch
|
|
|
- return true if ignore_search_indexing?(:update)
|
|
|
-
|
|
|
- # start background job to transfer data to search index
|
|
|
- return true if !SearchIndexBackend.enabled?
|
|
|
-
|
|
|
- SearchIndexJob.perform_later(self.class.to_s, id)
|
|
|
- true
|
|
|
- end
|
|
|
-
|
|
|
def search_index_indexable
|
|
|
Models.indexable.reject { |local_class| local_class == self.class }
|
|
|
end
|