Skip to content
代码片段 群组 项目
提交 c046e5a9 编辑于 作者: Vladimir Shushlin's avatar Vladimir Shushlin
浏览文件

Merge branch 'mmj-tidy-up' into 'master'

Use use_includes: false where necessary

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/137903



Merged-by: default avatarVladimir Shushlin <vshushlin@gitlab.com>
Approved-by: default avatarThong Kuah <tkuah@gitlab.com>
Approved-by: default avatarVladimir Shushlin <vshushlin@gitlab.com>
Reviewed-by: default avatarManoj M J <mmj@gitlab.com>
Co-authored-by: default avatarManoj M J <mmj@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -86,7 +86,7 @@ class CommitStatus < Ci::ApplicationRecord ...@@ -86,7 +86,7 @@ class CommitStatus < Ci::ApplicationRecord
scope :for_project_paths, -> (paths) do scope :for_project_paths, -> (paths) do
# Pluck is used to split this query. Splitting the query is required for database decomposition for `ci_*` tables. # Pluck is used to split this query. Splitting the query is required for database decomposition for `ci_*` tables.
# https://docs.gitlab.com/ee/development/database/transaction_guidelines.html#database-decomposition-and-sharding # https://docs.gitlab.com/ee/development/database/transaction_guidelines.html#database-decomposition-and-sharding
project_ids = Project.where_full_path_in(Array(paths)).pluck(:id) project_ids = Project.where_full_path_in(Array(paths), use_includes: false).pluck(:id)
for_project(project_ids) for_project(project_ids)
end end
......
...@@ -59,7 +59,7 @@ def allowed_project_configurations ...@@ -59,7 +59,7 @@ def allowed_project_configurations
return unless project_entries return unless project_entries
allowed_projects.where_full_path_in(project_entries.keys).map do |project| allowed_projects.where_full_path_in(project_entries.keys, use_includes: false).map do |project|
{ project_id: project.id, config: user_access_as } { project_id: project.id, config: user_access_as }
end end
end end
...@@ -70,7 +70,7 @@ def allowed_group_configurations ...@@ -70,7 +70,7 @@ def allowed_group_configurations
return unless group_entries return unless group_entries
allowed_groups.where_full_path_in(group_entries.keys).map do |group| allowed_groups.where_full_path_in(group_entries.keys, use_includes: false).map do |group|
{ group_id: group.id, config: user_access_as } { group_id: group.id, config: user_access_as }
end end
end end
......
...@@ -122,7 +122,7 @@ def orphan? ...@@ -122,7 +122,7 @@ def orphan?
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def project_id def project_id
@project_id ||= Project.where_full_path_in([full_path]).pluck(:id) @project_id ||= Project.where_full_path_in([full_path], use_includes: false).pluck(:id)
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
end end
......
...@@ -20,8 +20,7 @@ def find ...@@ -20,8 +20,7 @@ def find
# this logic cannot be placed in the NamespaceResolver due to N+1 # this logic cannot be placed in the NamespaceResolver due to N+1
scope = scope.without_project_namespaces if scope == Namespace scope = scope.without_project_namespaces if scope == Namespace
# `with_route` avoids an N+1 calculating full_path # `with_route` avoids an N+1 calculating full_path
scope = scope.where_full_path_in(full_paths).with_route scope = scope.where_full_path_in(full_paths)
.allow_cross_joins_across_databases(url: "https://gitlab.com/gitlab-org/gitlab/-/issues/420046")
scope.each do |model_instance| scope.each do |model_instance|
loader.call(model_instance.full_path.downcase, model_instance) loader.call(model_instance.full_path.downcase, model_instance)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册