Commit e00e54b69ca7cd1c4cfbb726b87372c479ff8b73
1 parent
46fa9218
Exists in
master
and in
4 other branches
Fix timeout error while showing the very large repo like git repo.
Showing
1 changed file
with
21 additions
and
4 deletions
Show diff stats
app/models/network/graph.rb
@@ -66,13 +66,30 @@ module Network | @@ -66,13 +66,30 @@ module Network | ||
66 | 66 | ||
67 | # Skip count that the target commit is displayed in center. | 67 | # Skip count that the target commit is displayed in center. |
68 | def count_to_display_commit_in_center | 68 | def count_to_display_commit_in_center |
69 | - commit_index = find_commits.index do |c| | ||
70 | - c.id == @commit.id | 69 | + offset = -1 |
70 | + skip = 0 | ||
71 | + while offset == -1 | ||
72 | + tmp_commits = find_commits(skip) | ||
73 | + if tmp_commits.size > 0 | ||
74 | + index = tmp_commits.index do |c| | ||
75 | + c.id == @commit.id | ||
76 | + end | ||
77 | + | ||
78 | + if index | ||
79 | + # Find the target commit | ||
80 | + offset = index + skip | ||
81 | + else | ||
82 | + skip += self.class.max_count | ||
83 | + end | ||
84 | + else | ||
85 | + # Cant't find the target commit in the repo. | ||
86 | + offset = 0 | ||
87 | + end | ||
71 | end | 88 | end |
72 | 89 | ||
73 | - if commit_index && (self.class.max_count / 2 < commit_index) then | 90 | + if self.class.max_count / 2 < offset then |
74 | # get max index that commit is displayed in the center. | 91 | # get max index that commit is displayed in the center. |
75 | - commit_index - self.class.max_count / 2 | 92 | + offset - self.class.max_count / 2 |
76 | else | 93 | else |
77 | 0 | 94 | 0 |
78 | end | 95 | end |