Mastodon/app/workers/scheduler/indexing_scheduler.rb
Vyr Cossont bb25616185 IndexingScheduler: fetch and import in batches (#24285)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
2026-07-11 13:42:14 -04:00

31 lines
559 B
Ruby

# frozen_string_literal: true
class Scheduler::IndexingScheduler
include Sidekiq::Worker
include Redisable
sidekiq_options retry: 0
def perform
return unless Chewy.enabled?
indexes.each do |type|
with_redis do |redis|
ids = redis.smembers("chewy:queue:#{type.name}")
type.import!(ids)
redis.pipelined do |pipeline|
ids.each { |id| pipeline.srem("chewy:queue:#{type.name}", id) }
end
end
end
end
private
def indexes
[AccountsIndex, TagsIndex, StatusesIndex]
end
end