mirror of
https://github.com/yingziwu/mastodon.git
synced 2026-02-14 22:33:19 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
6d173cec8e
28 changed files with 406 additions and 347 deletions
30
lib/chewy/strategy/custom_sidekiq.rb
Normal file
30
lib/chewy/strategy/custom_sidekiq.rb
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Chewy
|
||||
class Strategy
|
||||
class CustomSidekiq < Base
|
||||
class Worker
|
||||
include ::Sidekiq::Worker
|
||||
|
||||
sidekiq_options queue: 'pull'
|
||||
|
||||
def perform(type, ids, options = {})
|
||||
options[:refresh] = !Chewy.disable_refresh_async if Chewy.disable_refresh_async
|
||||
type.constantize.import!(ids, options)
|
||||
end
|
||||
end
|
||||
|
||||
def update(type, objects, _options = {})
|
||||
return unless Chewy.enabled?
|
||||
|
||||
ids = type.root.id ? Array.wrap(objects) : type.adapter.identify(objects)
|
||||
|
||||
return if ids.empty?
|
||||
|
||||
Worker.perform_async(type.name, ids)
|
||||
end
|
||||
|
||||
def leave; end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue