diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-03-18 23:17:52 -0700 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-03-18 23:17:52 -0700 |
commit | 924643198c924c19d0b468b27ee92077cefe7424 (patch) | |
tree | deec18b47f0c41f1678ab3d996df37318c9c36bc | |
parent | 7587a3b2fc0e0a3e39e969172f00391c2053e8b9 (diff) | |
parent | 92de0faf6e86d7fed33bc8989e3f2147c16450dd (diff) | |
download | gitlab-ce-924643198c924c19d0b468b27ee92077cefe7424.tar.gz |
Merge pull request #3252 from hiroponz/fix-timeout-large-repository
Fix timeout error while showing the network graph.
-rw-r--r-- | app/models/network/graph.rb | 47 | ||||
-rw-r--r-- | features/support/env.rb | 2 | ||||
-rw-r--r-- | spec/features/projects_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/security/project_access_spec.rb | 17 |
4 files changed, 46 insertions, 22 deletions
diff --git a/app/models/network/graph.rb b/app/models/network/graph.rb index 074ec371fd2..4b1abf5215e 100644 --- a/app/models/network/graph.rb +++ b/app/models/network/graph.rb @@ -25,15 +25,7 @@ module Network def collect_commits refs_cache = build_refs_cache - Grit::Commit.find_all( - @repo, - nil, - { - date_order: true, - max_count: self.class.max_count, - skip: count_to_display_commit_in_center - } - ) + find_commits(count_to_display_commit_in_center) .map do |commit| # Decorate with app/model/network/commit.rb Network::Commit.new(commit, refs_cache[commit.id]) @@ -74,18 +66,47 @@ module Network # Skip count that the target commit is displayed in center. def count_to_display_commit_in_center - commit_index = Grit::Commit.find_all(@repo, nil, {date_order: true}).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 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 @commits.sort do |a,b| if include_ref?(a) diff --git a/features/support/env.rb b/features/support/env.rb index f6f88955625..90a61dd16c6 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -28,8 +28,8 @@ require 'capybara/poltergeist' Capybara.javascript_driver = :poltergeist Spinach.hooks.on_tag("javascript") do ::Capybara.current_driver = ::Capybara.javascript_driver - ::Capybara.default_wait_time = 5 end +Capybara.default_wait_time = 10 DatabaseCleaner.strategy = :truncation diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index 7bc48260935..1ffc28bfa4e 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -11,7 +11,7 @@ describe "Projects" do end 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 diff --git a/spec/features/security/project_access_spec.rb b/spec/features/security/project_access_spec.rb index a35175102ec..a871cf01dd4 100644 --- a/spec/features/security/project_access_spec.rb +++ b/spec/features/security/project_access_spec.rb @@ -230,14 +230,17 @@ describe "Application access" do end describe "GET /project_code/files" do - subject { files_project_path(project) } + pending("ProjectsController#files have been deleted.") do - it { should be_allowed_for master } - it { should be_allowed_for reporter } - it { should be_denied_for :admin } - it { should be_denied_for guest } - it { should be_denied_for :user } - it { should be_denied_for :visitor } + subject { files_project_path(project) } + + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_denied_for :admin } + it { should be_denied_for guest } + it { should be_denied_for :user } + it { should be_denied_for :visitor } + end end end end |