Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2017-09-06 23:47:25 +0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2017-09-06 23:47:25 +0300
commitc2e99b40f71ca7036cc07596aae164e92378263b (patch)
tree85e912ba19b4091364206b63e55d1facf2e423d9 /app/helpers/tree_helper.rb
parent21935d85382989e38dd4cc12de55966e0c9b6eba (diff)
Implement fix for n+1 issue on `flatten_tree` helper
Diffstat (limited to 'app/helpers/tree_helper.rb')
-rw-r--r--app/helpers/tree_helper.rb4
1 files changed, 3 insertions, 1 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))