forked from e621ng/e621ng
add indexing jobs
This commit is contained in:
parent
0a50f5f4ea
commit
396d07a5d1
2
Procfile
2
Procfile
@ -1,5 +1,5 @@
|
||||
unicorn: bin/rails server -p 9000
|
||||
jobs: bin/rake jobs:work
|
||||
jobs: bundle exec sidekiq -c 1 -q low_prio -q tags -q default -q high_prio
|
||||
recommender: bundle exec ruby script/mock_services/recommender.rb
|
||||
iqdbs: bundle exec ruby script/mock_services/iqdbs.rb
|
||||
reportbooru: bundle exec ruby script/mock_services/reportbooru.rb
|
||||
|
@ -24,16 +24,16 @@ module Indexable
|
||||
end
|
||||
|
||||
def update_index(defer: true, priority: :high)
|
||||
# if defer
|
||||
# if priority == :high
|
||||
# IndexUpdateJob.perform_later(self.class.to_s, id)
|
||||
# elsif priority == :rebuild
|
||||
# IndexRebuildJob.perform_later(self.class.to_s, id)
|
||||
# else
|
||||
# raise ArgumentError, 'No such priority known'
|
||||
# end
|
||||
# else
|
||||
if defer
|
||||
if priority == :high
|
||||
IndexUpdateJob.perform_later(self.class.to_s, id)
|
||||
elsif priority == :rebuild
|
||||
IndexRebuildJob.perform_later(self.class.to_s, id)
|
||||
else
|
||||
raise ArgumentError, 'No such priority known'
|
||||
end
|
||||
else
|
||||
__elasticsearch__.index_document
|
||||
# end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
11
app/jobs/index_rebuild_job.rb
Normal file
11
app/jobs/index_rebuild_job.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IndexRebuildJob < ApplicationJob
|
||||
queue_as :low_prio
|
||||
|
||||
def perform(klass, id)
|
||||
obj = klass.constantize.find_by(id)
|
||||
obj.update_index(defer: false) if obj
|
||||
end
|
||||
end
|
||||
|
10
app/jobs/index_update_job.rb
Normal file
10
app/jobs/index_update_job.rb
Normal file
@ -0,0 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IndexUpdateJob < ApplicationJob
|
||||
queue_as :high_prio
|
||||
|
||||
def perform(klass, id)
|
||||
obj = klass.constantize.find_by(id)
|
||||
obj.update_index(defer: false) if obj
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user