0
0
Fork 0

Fix unnecessary queries when batch-removing statuses, 100x faster (#15387)

This commit is contained in:
Eugen Rochko 2020-12-22 17:13:55 +01:00 committed by GitHub
parent 67ebd61f11
commit 9915d11c0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 168 additions and 100 deletions

View file

@ -2,29 +2,10 @@
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
class CustomSidekiq < Sidekiq
def update(_type, _objects, _options = {})
super if Chewy.enabled?
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