diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-09-30 20:54:21 +0300 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-09-30 21:03:43 +0300 |
commit | 7f4452d4069b815612e53b7f20995137af608db2 (patch) | |
tree | ffe2ff8b577118a965b138a3f559a73bcec3bd4d /lib/banzai | |
parent | 227cc997fb107672e3293c56e0dcb1df72ad82d5 (diff) |
Preload project features in reference parser
Preloading of project_features mitigates N+1 queries when checking
references in other projects.
When loading projects for resources referenced in comments it
makes sense to include also associated project_features because
in the following step (`can_read_reference?(user, projects[node],
node)`) project features is used for checking permissions for the given
project.
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/reference_parser/base_parser.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/banzai/reference_parser/base_parser.rb b/lib/banzai/reference_parser/base_parser.rb index 3ab154a7b1c..334ba97bfb3 100644 --- a/lib/banzai/reference_parser/base_parser.rb +++ b/lib/banzai/reference_parser/base_parser.rb @@ -215,7 +215,7 @@ module Banzai # def projects_for_nodes(nodes) @projects_for_nodes ||= - grouped_objects_for_nodes(nodes, Project, 'data-project') + grouped_objects_for_nodes(nodes, Project.includes(:project_feature), 'data-project') end def can?(user, permission, subject = :global) |