ProjectFeature should be eager loaded with issue
To load issue 1, we see that in http://profiler.gitlap.com/20170916/328b0c66-074c-4e47-9df8-50595778d9c1.txt.gz ProjectFeature
took 835 ms to load. For example:
D, [2017-09-16T06:15:47.465287 #7732] DEBUG -- : ProjectFeature Load (293.1ms) SELECT "project_features".* FROM "project_features" WHERE "project_features"."project_id" = 561884 LIMIT 1 [["project_id", 561884]]
D, [2017-09-16T06:15:47.475348 #7732] DEBUG -- : ↳ app/models/project.rb:35:in `feature_available?'
D, [2017-09-16T06:15:47.475609 #7732] DEBUG -- : ↳ app/models/issue.rb:280:in `visible_to_user?'
D, [2017-09-16T06:15:47.475825 #7732] DEBUG -- : ↳ app/models/ability.rb:27:in `block (2 levels) in issues_readable_by_user'
D, [2017-09-16T06:15:47.568579 #7732] DEBUG -- : ↳ app/models/ability.rb:27:in `select'
D, [2017-09-16T06:15:47.568904 #7732] DEBUG -- : ↳ app/models/ability.rb:27:in `block in issues_readable_by_user'
D, [2017-09-16T06:15:47.569125 #7732] DEBUG -- : ↳ lib/declarative_policy/preferred_scope.rb:7:in `with_preferred_scope'
D, [2017-09-16T06:15:47.569348 #7732] DEBUG -- : ↳ lib/declarative_policy/preferred_scope.rb:17:in `user_scope'
D, [2017-09-16T06:15:47.569569 #7732] DEBUG -- : ↳ app/models/ability.rb:26:in `issues_readable_by_user'
D, [2017-09-16T06:15:47.570032 #7732] DEBUG -- : ↳ lib/banzai/reference_parser/issue_parser.rb:10:in `nodes_visible_to_user'
D, [2017-09-16T06:15:47.570390 #7732] DEBUG -- : ↳ lib/banzai/redactor.rb:70:in `block in nodes_visible_to_user'
D, [2017-09-16T06:15:47.570597 #7732] DEBUG -- : ↳ lib/banzai/redactor.rb:67:in `each'
D, [2017-09-16T06:15:47.570806 #7732] DEBUG -- : ↳ lib/banzai/redactor.rb:67:in `nodes_visible_to_user'
D, [2017-09-16T06:15:47.571143 #7732] DEBUG -- : ↳ lib/banzai/redactor.rb:32:in `redact_document_nodes'
D, [2017-09-16T06:15:47.571493 #7732] DEBUG -- : ↳ lib/banzai/redactor.rb:24:in `redact'
D, [2017-09-16T06:15:47.571853 #7732] DEBUG -- : ↳ lib/banzai/object_renderer.rb:71:in `redact_documents'
D, [2017-09-16T06:15:47.572320 #7732] DEBUG -- : ↳ lib/banzai/object_renderer.rb:36:in `render'
D, [2017-09-16T06:15:47.578433 #7732] DEBUG -- : ↳ lib/banzai/note_renderer.rb:18:in `render'
D, [2017-09-16T06:15:47.578816 #7732] DEBUG -- : ↳ app/controllers/concerns/renders_notes.rb:6:in `prepare_notes_for_rendering'
D, [2017-09-16T06:15:47.579108 #7732] DEBUG -- : ↳ app/controllers/projects/issues_controller.rb:77:in `show'
D, [2017-09-16T06:15:47.579427 #7732] DEBUG -- : ↳ app/controllers/application_controller.rb:334:in `set_locale'
D, [2017-09-16T06:15:47.579848 #7732] DEBUG -- : ↳ lib/gitlab/jira/middleware.rb:15:in `call'
It seems to me we might be able to solve this with the following:
diff --git a/lib/banzai/reference_parser/issue_parser.rb b/lib/banzai/reference_parser/issue_parser.rb
index a65bbe2395..32dd18834e 100644
--- a/lib/banzai/reference_parser/issue_parser.rb
+++ b/lib/banzai/reference_parser/issue_parser.rb
@@ -34,7 +34,8 @@ module Banzai
{ namespace: :owner },
{ group: [:owners, :group_members] },
:invited_groups,
- :project_members
+ :project_members,
+ :project_feature,
]
}
),
Interestingly enough, this is already part of merge requests via 52d049b4.