speed up account settings users
fixes: CNVS-14742 Preloads admin users communication channels. In role overrides it changes the class call for context to index by context_id. Since we know they should always be accounts. Test Plan: - The initial Account settings page should load quicker. - Full permission regression testing. Change-Id: Iadeb55e3b6163421605d1829fa4789c5e1fe9a7e Reviewed-on: https://gerrit.instructure.com/40360 Reviewed-by: Cody Cutrer <cody@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: August Thornton <august@instructure.com> QA-Review: Jeremy Putnam <jeremyp@instructure.com> Product-Review: Nick Cloward <ncloward@instructure.com>
This commit is contained in:
parent
62ffcac4f9
commit
79d634a0f8
|
@ -483,7 +483,7 @@ class AccountsController < ApplicationController
|
||||||
end
|
end
|
||||||
load_course_right_side
|
load_course_right_side
|
||||||
@account_users = @account.account_users
|
@account_users = @account.account_users
|
||||||
AccountUser.send(:preload_associations, @account_users, :user)
|
AccountUser.send(:preload_associations, @account_users, user: :communication_channels)
|
||||||
order_hash = {}
|
order_hash = {}
|
||||||
@account.available_account_roles.each_with_index do |type, idx|
|
@account.available_account_roles.each_with_index do |type, idx|
|
||||||
order_hash[type] = idx
|
order_hash[type] = idx
|
||||||
|
|
|
@ -867,12 +867,12 @@ class RoleOverride < ActiveRecord::Base
|
||||||
overrides = @@role_override_chain[permissionless_key] ||= begin
|
overrides = @@role_override_chain[permissionless_key] ||= begin
|
||||||
role_context.shard.activate do
|
role_context.shard.activate do
|
||||||
account_ids = context.account_chain_ids(include_site_admin: true).reverse
|
account_ids = context.account_chain_ids(include_site_admin: true).reverse
|
||||||
overrides = RoleOverride.where(:context_id => account_ids, :enrollment_type => generated_permission[:enrollment_type].to_s).group_by(&:permission)
|
overrides = RoleOverride.where(:context_id => account_ids, :context_type => 'Account', :enrollment_type => generated_permission[:enrollment_type].to_s).group_by(&:permission)
|
||||||
# every context has to be represented so that we can't miss role_context below
|
# every context has to be represented so that we can't miss role_context below
|
||||||
overrides.each_key do |permission|
|
overrides.each_key do |permission|
|
||||||
overrides_by_account = overrides[permission].index_by { |override| [override.context_id, override.context.class.base_class.name] }
|
overrides_by_account = overrides[permission].index_by(&:context_id)
|
||||||
overrides[permission] = account_ids.map do |account_id|
|
overrides[permission] = account_ids.map do |account_id|
|
||||||
overrides_by_account[[account_id, 'Account']] || RoleOverride.new { |ro| ro.context_id = account_id; ro.context_type = 'Account' }
|
overrides_by_account[account_id] || RoleOverride.new { |ro| ro.context_id = account_id; ro.context_type = 'Account' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
overrides
|
overrides
|
||||||
|
|
Loading…
Reference in New Issue