forked from e621ng/e621ng
[Elasticsearch] Move more code out of indexable
This commit is contained in:
parent
5d791f9803
commit
f1d5864724
@ -10,20 +10,5 @@ module Indexable
|
||||
base.include DocumentStore::Model
|
||||
|
||||
base.index_name("#{base.model_name.plural}_#{Rails.env}")
|
||||
|
||||
base.after_commit on: %i[create update] do
|
||||
update_index
|
||||
end
|
||||
|
||||
base.after_commit on: [:destroy] do
|
||||
document_store_delete_document(refresh: Rails.env.test?.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
def update_index(queue: :high_prio)
|
||||
# TODO: race condition hack, makes tests SLOW!!!
|
||||
return document_store_update_index refresh: "true" if Rails.env.test?
|
||||
|
||||
IndexUpdateJob.set(queue: queue).perform_later(self.class.to_s, id)
|
||||
end
|
||||
end
|
||||
|
@ -2,6 +2,21 @@ module DocumentStore
|
||||
module Model
|
||||
def self.included(klass)
|
||||
klass.extend(ClassMethods)
|
||||
|
||||
klass.after_commit on: %i[create update] do
|
||||
update_index
|
||||
end
|
||||
|
||||
klass.after_commit on: [:destroy] do
|
||||
document_store_delete_document(refresh: Rails.env.test?.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
def update_index(queue: :high_prio)
|
||||
# TODO: race condition hack, makes tests SLOW!!!
|
||||
return document_store_update_index refresh: "true" if Rails.env.test?
|
||||
|
||||
IndexUpdateJob.set(queue: queue).perform_later(self.class.to_s, id)
|
||||
end
|
||||
|
||||
def document_store_update_index(refresh: "false")
|
||||
|
Loading…
Reference in New Issue
Block a user