diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-20 15:19:03 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-20 15:19:03 +0000 |
commit | 14bd84b61276ef29b97d23642d698de769bacfd2 (patch) | |
tree | f9eba90140c1bd874211dea17750a0d422c04080 /lib/banzai/reference_parser | |
parent | 891c388697b2db0d8ee0c8358a9bdbf6dc56d581 (diff) | |
download | gitlab-ce-14bd84b61276ef29b97d23642d698de769bacfd2.tar.gz |
Add latest changes from gitlab-org/gitlab@15-10-stable-eev15.10.0-rc42
Diffstat (limited to 'lib/banzai/reference_parser')
-rw-r--r-- | lib/banzai/reference_parser/commit_parser.rb | 7 | ||||
-rw-r--r-- | lib/banzai/reference_parser/commit_range_parser.rb | 7 | ||||
-rw-r--r-- | lib/banzai/reference_parser/issue_parser.rb | 24 | ||||
-rw-r--r-- | lib/banzai/reference_parser/merge_request_parser.rb | 22 |
4 files changed, 27 insertions, 33 deletions
diff --git a/lib/banzai/reference_parser/commit_parser.rb b/lib/banzai/reference_parser/commit_parser.rb index c51f4976c28..88896970bc6 100644 --- a/lib/banzai/reference_parser/commit_parser.rb +++ b/lib/banzai/reference_parser/commit_parser.rb @@ -32,13 +32,6 @@ module Banzai commits end - def nodes_visible_to_user(user, nodes) - projects = lazy { projects_for_nodes(nodes) } - user.preloaded_member_roles_for_projects(projects.values) if user - - super - end - private def can_read_reference?(user, ref_project, node) diff --git a/lib/banzai/reference_parser/commit_range_parser.rb b/lib/banzai/reference_parser/commit_range_parser.rb index 3d09bc83151..fb4a392105f 100644 --- a/lib/banzai/reference_parser/commit_range_parser.rb +++ b/lib/banzai/reference_parser/commit_range_parser.rb @@ -38,13 +38,6 @@ module Banzai range.valid_commits? ? range : nil end - def nodes_visible_to_user(user, nodes) - projects = lazy { projects_for_nodes(nodes) } - user.preloaded_member_roles_for_projects(projects.values) if user - - super - end - private def can_read_reference?(user, ref_project, node) diff --git a/lib/banzai/reference_parser/issue_parser.rb b/lib/banzai/reference_parser/issue_parser.rb index 6b1491cc56b..a5862fbaac4 100644 --- a/lib/banzai/reference_parser/issue_parser.rb +++ b/lib/banzai/reference_parser/issue_parser.rb @@ -57,18 +57,22 @@ module Banzai end def records_for_nodes(nodes) + node_includes = [ + :namespace, + :author, + :assignees, + { + # These associations are primarily used for checking permissions. + # Eager loading these ensures we don't end up running dozens of + # queries in this process. + project: [:namespace, :project_feature, :route] + } + ] + node_includes << :milestone if context.options[:extended_preload] + @issues_for_nodes ||= grouped_objects_for_nodes( nodes, - Issue.all.includes( - :author, - :assignees, - { - # These associations are primarily used for checking permissions. - # Eager loading these ensures we don't end up running dozens of - # queries in this process. - project: [:namespace, :project_feature, :route] - } - ), + Issue.all.includes(node_includes), self.class.data_attribute ) end diff --git a/lib/banzai/reference_parser/merge_request_parser.rb b/lib/banzai/reference_parser/merge_request_parser.rb index 3e28f06b783..2bd06e79e96 100644 --- a/lib/banzai/reference_parser/merge_request_parser.rb +++ b/lib/banzai/reference_parser/merge_request_parser.rb @@ -19,17 +19,21 @@ module Banzai end def records_for_nodes(nodes) + node_includes = [ + :author, + :assignees, + { + # These associations are primarily used for checking permissions. + # Eager loading these ensures we don't end up running dozens of + # queries in this process. + target_project: [{ namespace: :route }, :project_feature, :route] + } + ] + node_includes << :milestone if context.options[:extended_preload] + @merge_requests_for_nodes ||= grouped_objects_for_nodes( nodes, - MergeRequest.includes( - :author, - :assignees, - { - # These associations are primarily used for checking permissions. - # Eager loading these ensures we don't end up running dozens of - # queries in this process. - target_project: [{ namespace: :route }, :project_feature, :route] - }), + MergeRequest.includes(node_includes), self.class.data_attribute ) end |