don't search for more than 100 merge candidates
closes #CORE-2249 Change-Id: I4f857b84dcf0fccb43661c0d908b7786c871b88e Reviewed-on: https://gerrit.instructure.com/175251 Reviewed-by: Cody Cutrer <cody@instructure.com> Tested-by: Jenkins QA-Review: James Williams <jamesw@instructure.com> Product-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
0fb6baba90
commit
971f5f9a95
|
@ -1,5 +1,5 @@
|
|||
<%
|
||||
current_host = (HostUrl.context_host(asset.merge_candidates.first.pseudonym.account) rescue nil) || HostUrl.default_host
|
||||
current_host = (HostUrl.context_host(asset.merge_candidates(true).first.pseudonym.account) rescue nil) || HostUrl.default_host
|
||||
new_host = (HostUrl.context_host((asset.pseudonym || asset.user.pseudonym).account) rescue nil) || HostUrl.default_host
|
||||
%>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<%
|
||||
current_host = (HostUrl.context_host(asset.merge_candidates.first.pseudonym.account) rescue nil) || HostUrl.default_host
|
||||
current_host = (HostUrl.context_host(asset.merge_candidates(true).first.pseudonym.account) rescue nil) || HostUrl.default_host
|
||||
new_host = (HostUrl.context_host((asset.pseudonym || asset.user.pseudonym).account) rescue nil) || HostUrl.default_host
|
||||
%>
|
||||
|
||||
|
|
|
@ -459,8 +459,13 @@ class CommunicationChannel < ActiveRecord::Base
|
|||
scope = CommunicationChannel.active.by_path(self.path).of_type(self.path_type)
|
||||
merge_candidates = {}
|
||||
Shard.with_each_shard(shards) do
|
||||
scope = scope.shard(Shard.current)
|
||||
scope.where("user_id<>?", self.user_id).preload(:user).map(&:user).select do |u|
|
||||
scope = scope.shard(Shard.current).where("user_id<>?", self.user_id)
|
||||
|
||||
limit = Setting.get("merge_candidate_search_limit", "100").to_i
|
||||
ccs = scope.preload(:user).limit(limit + 1).to_a
|
||||
return [] if ccs.count > limit # just bail if things are getting out of hand
|
||||
|
||||
ccs.map(&:user).select do |u|
|
||||
result = merge_candidates.fetch(u.global_id) do
|
||||
merge_candidates[u.global_id] = (u.all_active_pseudonyms.length != 0)
|
||||
end
|
||||
|
|
|
@ -269,11 +269,16 @@ module SIS
|
|||
# find all CCs for this user, and active conflicting CCs for all users
|
||||
# unless we're deleting this user, then only find CCs for this user
|
||||
if status_is_active
|
||||
ccs = CommunicationChannel.where("workflow_state='active' OR user_id=?", user)
|
||||
cc_scope = CommunicationChannel.where("workflow_state='active' OR user_id=?", user)
|
||||
else
|
||||
ccs = user.communication_channels
|
||||
cc_scope = user.communication_channels
|
||||
end
|
||||
cc_scope = cc_scope.email.by_path(user_row.email)
|
||||
limit = Setting.get("merge_candidate_search_limit", "100").to_i
|
||||
ccs = cc_scope.limit(limit + 1).to_a
|
||||
if ccs.count > limit
|
||||
ccs = cc_scope.where(:user_id => user).to_a # don't bother with merge candidates anymore
|
||||
end
|
||||
ccs = ccs.email.by_path(user_row.email).to_a
|
||||
|
||||
# sis_cc could be set from the previous user, if we're not on a transaction boundary,
|
||||
# and the previous user had an sis communication channel, and this user doesn't have one
|
||||
|
|
Loading…
Reference in New Issue