change sidekiq queueing to bulk push (#3536)

This commit is contained in:
takayamaki 2017-06-04 07:11:15 +09:00 committed by Eugen Rochko
parent ce7c0def88
commit 3eedad2737
6 changed files with 23 additions and 9 deletions

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
require 'sidekiq-bulk'
class FanOutOnWriteService < BaseService
# Push a status into home and mentions feeds
# @param [Status] status
@ -34,8 +36,10 @@ class FanOutOnWriteService < BaseService
def deliver_to_followers(status)
Rails.logger.debug "Delivering status #{status.id} to followers"
status.account.followers.where(domain: nil).joins(:user).where('users.current_sign_in_at > ?', 14.days.ago).select(:id).reorder(nil).find_each do |follower|
FeedInsertWorker.perform_async(status.id, follower.id)
status.account.followers.where(domain: nil).joins(:user).where('users.current_sign_in_at > ?', 14.days.ago).select(:id).reorder(nil).find_in_batches do |followers|
FeedInsertWorker.push_bulk(followers) do |follower|
[status.id, follower.id]
end
end
end