mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-30 04:14:36 +00:00
5c42f47617
It's possible that after commit callbacks were not firing when exceptions occurred in the process. Also, the default Sidekiq strategy does not push indexing jobs immediately, which is not necessary and could be part of the issue too.
31 lines
685 B
Ruby
31 lines
685 B
Ruby
# 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
|