Commit 4696307c authored by Fosco Marotto's avatar Fosco Marotto

Use a writing role for some sidekiq worker reads

parent de7d71e0
......@@ -4,6 +4,8 @@ class BootstrapTimelineWorker
include Sidekiq::Worker
def perform(account_id)
BootstrapTimelineService.new.call(Account.find(account_id))
ActiveRecord::Base.connected_to(role: :writing) do
BootstrapTimelineService.new.call(Account.find(account_id))
end
end
end
......@@ -8,10 +8,12 @@ class LocalNotificationWorker
def perform(receiver_account_id, activity_id = nil, activity_class_name = nil)
return true if activity_id.nil? or activity_class_name.nil?
receiver = Account.find(receiver_account_id)
activity = activity_class_name.constantize.find(activity_id)
ActiveRecord::Base.connected_to(role: :writing) do
receiver = Account.find(receiver_account_id)
activity = activity_class_name.constantize.find(activity_id)
NotifyService.new.call(receiver, activity)
NotifyService.new.call(receiver, activity)
end
rescue ActiveRecord::RecordNotFound
true
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment