diff options
author | Alejandro RodrÃguez <alejorro70@gmail.com> | 2017-09-06 17:47:25 -0300 |
---|---|---|
committer | Alejandro RodrÃguez <alejorro70@gmail.com> | 2017-09-06 17:47:25 -0300 |
commit | c2e99b40f71ca7036cc07596aae164e92378263b (patch) | |
tree | 85e912ba19b4091364206b63e55d1facf2e423d9 /app | |
parent | 21935d85382989e38dd4cc12de55966e0c9b6eba (diff) | |
download | gitlab-ce-c2e99b40f71ca7036cc07596aae164e92378263b.tar.gz |
Implement fix for n+1 issue on `flatten_tree` helpergitaly-tree-entries-fix
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/tree_helper.rb | 4 | ||||
-rw-r--r-- | app/views/projects/tree/_tree_item.html.haml | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index e0d3e9b88f3..95dbdc8ec46 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -99,7 +99,9 @@ module TreeHelper end # returns the relative path of the first subdir that doesn't have only one directory descendant - def flatten_tree(tree) + def flatten_tree(root_path, tree) + return tree.flat_path.sub(/\A#{root_path}\//, '') if tree.flat_path.present? + subtree = Gitlab::Git::Tree.where(@repository, @commit.id, tree.path) if subtree.count == 1 && subtree.first.dir? return tree_join(tree.name, flatten_tree(subtree.first)) diff --git a/app/views/projects/tree/_tree_item.html.haml b/app/views/projects/tree/_tree_item.html.haml index 0c9c8750f2c..56197382a70 100644 --- a/app/views/projects/tree/_tree_item.html.haml +++ b/app/views/projects/tree/_tree_item.html.haml @@ -1,7 +1,7 @@ %tr{ class: "tree-item #{tree_hex_class(tree_item)}" } %td.tree-item-file-name = tree_icon(type, tree_item.mode, tree_item.name) - - path = flatten_tree(tree_item) + - path = flatten_tree(@path, tree_item) = link_to project_tree_path(@project, tree_join(@id || @commit.id, path)), title: path do %span.str-truncated= path %td.hidden-xs.tree-commit |