move account notification queries to slave
closes #LA-879 Change-Id: I59029d363796b6ddabd25a01a43d4abe86548497 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/232677 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Reviewed-by: Clint Furse <cfurse@instructure.com> QA-Review: Clint Furse <cfurse@instructure.com> Product-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
1329ad3e3d
commit
f7bc651bbf
|
@ -67,6 +67,7 @@ class AccountNotification < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.for_user_and_account(user, root_account)
|
||||
Shackles.activate(:slave) do
|
||||
if root_account.site_admin?
|
||||
current = self.for_account(root_account)
|
||||
else
|
||||
|
@ -127,8 +128,10 @@ class AccountNotification < ActiveRecord::Base
|
|||
# applicable, they probably need to be cleared out.
|
||||
current_ids = current.map(&:id)
|
||||
if !(closed_ids - current_ids).empty?
|
||||
Shackles.activate(:master) do
|
||||
user.set_preference(:closed_notifications, closed_ids & current_ids)
|
||||
end
|
||||
end
|
||||
current.reject! { |announcement| closed_ids.include?(announcement.id) }
|
||||
|
||||
# filter out announcements that have a periodic cycle of display,
|
||||
|
@ -149,6 +152,7 @@ class AccountNotification < ActiveRecord::Base
|
|||
|
||||
current
|
||||
end
|
||||
end
|
||||
|
||||
def self.for_account(root_account, all_visible_account_ids=nil)
|
||||
# Refreshes every 10 minutes at the longest
|
||||
|
|
Loading…
Reference in New Issue