indexing_scheduler.rb 548 B

12345678910111213141516171819202122232425262728
  1. # frozen_string_literal: true
  2. class Scheduler::IndexingScheduler
  3. include Sidekiq::Worker
  4. include Redisable
  5. sidekiq_options retry: 0
  6. def perform
  7. return unless Chewy.enabled?
  8. indexes.each do |type|
  9. with_redis do |redis|
  10. ids = redis.smembers("chewy:queue:#{type.name}")
  11. type.import!(ids)
  12. redis.pipelined do |pipeline|
  13. ids.each { |id| pipeline.srem("chewy:queue:#{type.name}", id) }
  14. end
  15. end
  16. end
  17. end
  18. def indexes
  19. [AccountsIndex, TagsIndex, StatusesIndex]
  20. end
  21. end