summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-04-23 22:27:13 -0700
committerStan Hu <stanhu@gmail.com>2017-04-23 22:30:14 -0700
commitbbcb7e5e96b030b4b2a3d03ee9c715853e6528be (patch)
tree51316b1adc7c54403d3d60ff0ea22a806d0a07ef
parent1005389f70070245092c1ae5f3f9b10b8e7c102e (diff)
downloadgitlab-ce-bbcb7e5e96b030b4b2a3d03ee9c715853e6528be.tar.gz
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
-rw-r--r--app/views/shared/milestones/_issuable.html.haml2
-rw-r--r--changelogs/unreleased/sh-optimize-milestone-polymorphic-url.yml4
2 files changed, 5 insertions, 1 deletions
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} &middot;
diff --git a/changelogs/unreleased/sh-optimize-milestone-polymorphic-url.yml b/changelogs/unreleased/sh-optimize-milestone-polymorphic-url.yml
new file mode 100644
index 00000000000..ad62c896b04
--- /dev/null
+++ b/changelogs/unreleased/sh-optimize-milestone-polymorphic-url.yml
@@ -0,0 +1,4 @@
+---
+title: Eliminate N+1 queries in loading namespaces for every issuable in milestones
+merge_request:
+author: