BigW Consortium Gitlab

Commit bbcb7e5e by Stan Hu

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
parent 1005389f
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
- base_url_args = [project.namespace.becomes(Namespace), project, issuable_type] - base_url_args = [project.namespace.becomes(Namespace), project, issuable_type]
- can_update = can?(current_user, :"update_#{issuable.to_ability_name}", issuable) - 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 %span
- if show_project_name - if show_project_name
%strong #{project.name} · %strong #{project.name} ·
......
---
title: Eliminate N+1 queries in loading namespaces for every issuable in milestones
merge_request:
author:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment