summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-12 10:24:58 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-12 10:24:58 +0000
commit630be84add608572e1edd245032cd369a0f1e680 (patch)
treebc96754197fbf17a940e0e85a5f53703f6b67ef6
parent9fd6c3d591fb56e50a9cdbbaac557383e3ef86a7 (diff)
parentfcb0b76c32b3512ead419a4451e9cc632270fc89 (diff)
downloadgitlab-ce-630be84add608572e1edd245032cd369a0f1e680.tar.gz
Merge branch 'files-rational-git-log' into 'master'
Split commit logs loading #### Before this MR When visit files tab we have ajax call that loads all last commits for files inside directory. Load time depends on amount of files in directory. So if directory has 100 files - you may need to wait up to 20 seconds to get last commits info of files. Still if you do navigation at this time the request still wait for processing taking workers busy. If several people try to navigate through big repository directories - you will see huge performance drop. #### After this MR Load last commits only for first 10 entries. It usually takes not more then a second (even for huge repos). If user still on the same page - do next ajax call and get 10 more entries. If user navigate to another directory - stop ajax calls for this directory. So for cases when you want navigate to nested directory - you don't have long-running ajax calls that takes workers and makes app unusable for other users - - - Fixes #1229
-rw-r--r--app/controllers/projects/refs_controller.rb20
-rw-r--r--app/views/projects/refs/logs_tree.js.haml10
2 files changed, 27 insertions, 3 deletions
diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb
index 7b8026cff9f..8834a995081 100644
--- a/app/controllers/projects/refs_controller.rb
+++ b/app/controllers/projects/refs_controller.rb
@@ -31,9 +31,23 @@ class Projects::RefsController < Projects::ApplicationController
end
def logs_tree
- contents = tree.entries
- @logs = contents.map do |content|
- file = params[:path] ? File.join(params[:path], content.name) : content.name
+ @offset = if params[:offset].present?
+ params[:offset].to_i
+ else
+ 0
+ end
+
+ @limit = 10
+
+ @path = params[:path]
+
+ contents = []
+ contents += tree.trees
+ contents += tree.blobs
+ contents += tree.submodules
+
+ @logs = contents[@offset, @limit].to_a.map do |content|
+ file = @path ? File.join(@path, content.name) : content.name
last_commit = @repo.last_commit_for_path(@commit.id, file)
{
file_name: content.name,
diff --git a/app/views/projects/refs/logs_tree.js.haml b/app/views/projects/refs/logs_tree.js.haml
index e7343e0997f..948a21aa816 100644
--- a/app/views/projects/refs/logs_tree.js.haml
+++ b/app/views/projects/refs/logs_tree.js.haml
@@ -7,3 +7,13 @@
var row = $("table.table_#{@hex_path} tr.file_#{hexdigest(file_name)}");
row.find("td.tree_time_ago").html('#{escape_javascript time_ago_with_tooltip(commit.committed_date)}');
row.find("td.tree_commit").html('#{escape_javascript render("projects/tree/tree_commit_column", commit: commit)}');
+
+- if @logs.present?
+ :plain
+ var current_url = location.href.replace(/\/?$/, '/');
+ var log_url = '#{project_tree_url(@project, tree_join(@ref, @path || '/'))}'.replace(/\/?$/, '/');
+ if(current_url == log_url) {
+ // Load 10 more commit log for each file in tree
+ // if we still on the same page
+ ajaxGet('#{logs_file_project_ref_path(@project, @ref, @path || '/', offset: (@offset + @limit))}');
+ }