Merge pull request #3252 from hiroponz/fix-timeout-large-repository
Fix timeout error while showing the network graph.
This commit is contained in:
commit
924643198c
4 changed files with 46 additions and 22 deletions
|
@ -25,15 +25,7 @@ module Network
|
||||||
def collect_commits
|
def collect_commits
|
||||||
refs_cache = build_refs_cache
|
refs_cache = build_refs_cache
|
||||||
|
|
||||||
Grit::Commit.find_all(
|
find_commits(count_to_display_commit_in_center)
|
||||||
@repo,
|
|
||||||
nil,
|
|
||||||
{
|
|
||||||
date_order: true,
|
|
||||||
max_count: self.class.max_count,
|
|
||||||
skip: count_to_display_commit_in_center
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.map do |commit|
|
.map do |commit|
|
||||||
# Decorate with app/model/network/commit.rb
|
# Decorate with app/model/network/commit.rb
|
||||||
Network::Commit.new(commit, refs_cache[commit.id])
|
Network::Commit.new(commit, refs_cache[commit.id])
|
||||||
|
@ -74,18 +66,47 @@ module Network
|
||||||
|
|
||||||
# Skip count that the target commit is displayed in center.
|
# Skip count that the target commit is displayed in center.
|
||||||
def count_to_display_commit_in_center
|
def count_to_display_commit_in_center
|
||||||
commit_index = Grit::Commit.find_all(@repo, nil, {date_order: true}).index do |c|
|
offset = -1
|
||||||
c.id == @commit.id
|
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
|
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.
|
# get max index that commit is displayed in the center.
|
||||||
commit_index - self.class.max_count / 2
|
offset - self.class.max_count / 2
|
||||||
else
|
else
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_commits(skip = 0)
|
||||||
|
Grit::Commit.find_all(
|
||||||
|
@repo,
|
||||||
|
nil,
|
||||||
|
{
|
||||||
|
date_order: true,
|
||||||
|
max_count: self.class.max_count,
|
||||||
|
skip: skip
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def commits_sort_by_ref
|
def commits_sort_by_ref
|
||||||
@commits.sort do |a,b|
|
@commits.sort do |a,b|
|
||||||
if include_ref?(a)
|
if include_ref?(a)
|
||||||
|
|
|
@ -28,8 +28,8 @@ require 'capybara/poltergeist'
|
||||||
Capybara.javascript_driver = :poltergeist
|
Capybara.javascript_driver = :poltergeist
|
||||||
Spinach.hooks.on_tag("javascript") do
|
Spinach.hooks.on_tag("javascript") do
|
||||||
::Capybara.current_driver = ::Capybara.javascript_driver
|
::Capybara.current_driver = ::Capybara.javascript_driver
|
||||||
::Capybara.default_wait_time = 5
|
|
||||||
end
|
end
|
||||||
|
Capybara.default_wait_time = 10
|
||||||
|
|
||||||
|
|
||||||
DatabaseCleaner.strategy = :truncation
|
DatabaseCleaner.strategy = :truncation
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe "Projects" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should be correct path" do
|
it "should be correct path" do
|
||||||
expect { click_link "Remove" }.to change {Project.count}.by(-1)
|
expect { click_link "Remove project" }.to change {Project.count}.by(-1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -230,14 +230,17 @@ describe "Application access" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET /project_code/files" do
|
describe "GET /project_code/files" do
|
||||||
subject { files_project_path(project) }
|
pending("ProjectsController#files have been deleted.") do
|
||||||
|
|
||||||
it { should be_allowed_for master }
|
subject { files_project_path(project) }
|
||||||
it { should be_allowed_for reporter }
|
|
||||||
it { should be_denied_for :admin }
|
it { should be_allowed_for master }
|
||||||
it { should be_denied_for guest }
|
it { should be_allowed_for reporter }
|
||||||
it { should be_denied_for :user }
|
it { should be_denied_for :admin }
|
||||||
it { should be_denied_for :visitor }
|
it { should be_denied_for guest }
|
||||||
|
it { should be_denied_for :user }
|
||||||
|
it { should be_denied_for :visitor }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue