From bbcb7e5e96b030b4b2a3d03ee9c715853e6528be Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sun, 23 Apr 2017 22:27:13 -0700 Subject: Eliminate N+1 queries in loading namespaces for every issuable in milestones If we rely on the helper functions in `GitlabRoutingHelper` for `merge_request_path`, we end up calling a database query to look up the Namespace association for every merge request since `entity.project.namespace` is called. By reusing the project defined in the controller, we avoid that problem. Partial fix to #27387 --- app/views/shared/milestones/_issuable.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/views/shared') diff --git a/app/views/shared/milestones/_issuable.html.haml b/app/views/shared/milestones/_issuable.html.haml index 4c7d69d40d5..13a4175fd33 100644 --- a/app/views/shared/milestones/_issuable.html.haml +++ b/app/views/shared/milestones/_issuable.html.haml @@ -5,7 +5,7 @@ - base_url_args = [project.namespace.becomes(Namespace), project, issuable_type] - can_update = can?(current_user, :"update_#{issuable.to_ability_name}", issuable) -%li{ id: dom_id(issuable, 'sortable'), class: "issuable-row #{'is-disabled' unless can_update}", 'data-iid' => issuable.iid, 'data-id' => issuable.id, 'data-url' => polymorphic_path(issuable) } +%li{ id: dom_id(issuable, 'sortable'), class: "issuable-row #{'is-disabled' unless can_update}", 'data-iid' => issuable.iid, 'data-id' => issuable.id, 'data-url' => polymorphic_path([project.namespace.becomes(Namespace), project, issuable]) } %span - if show_project_name %strong #{project.name} · -- cgit v1.2.1