summaryrefslogtreecommitdiff
path: root/app/models/network
diff options
context:
space:
mode:
authorSato Hiroyuki <sathiroyuki@gmail.com>2013-03-19 10:22:55 +0900
committerSato Hiroyuki <sathiroyuki@gmail.com>2013-03-19 10:36:40 +0900
commite00e54b69ca7cd1c4cfbb726b87372c479ff8b73 (patch)
tree92c2eb9e2a72d63345dab197dec375f50e65d4db /app/models/network
parent46fa92187d6c076619e9cd58877e03c6d15a1f03 (diff)
downloadgitlab-ce-e00e54b69ca7cd1c4cfbb726b87372c479ff8b73.tar.gz
Fix timeout error while showing the very large repo like git repo.
Diffstat (limited to 'app/models/network')
-rw-r--r--app/models/network/graph.rb25
1 files changed, 21 insertions, 4 deletions
diff --git a/app/models/network/graph.rb b/app/models/network/graph.rb
index 16512b90f77..4b1abf5215e 100644
--- a/app/models/network/graph.rb
+++ b/app/models/network/graph.rb
@@ -66,13 +66,30 @@ module Network
# Skip count that the target commit is displayed in center.
def count_to_display_commit_in_center
- commit_index = find_commits.index do |c|
- c.id == @commit.id
+ offset = -1
+ skip = 0
+ while offset == -1
+ tmp_commits = find_commits(skip)
+ if tmp_commits.size > 0
+ index = tmp_commits.index do |c|
+ c.id == @commit.id
+ end
+
+ if index
+ # Find the target commit
+ offset = index + skip
+ else
+ skip += self.class.max_count
+ end
+ else
+ # Cant't find the target commit in the repo.
+ offset = 0
+ end
end
- if commit_index && (self.class.max_count / 2 < commit_index) then
+ if self.class.max_count / 2 < offset then
# get max index that commit is displayed in the center.
- commit_index - self.class.max_count / 2
+ offset - self.class.max_count / 2
else
0
end