diff options
author | Brett Walker <bwalker@gitlab.com> | 2017-10-12 16:31:43 +0300 |
---|---|---|
committer | Brett Walker <bwalker@gitlab.com> | 2017-10-12 16:31:43 +0300 |
commit | 528f9cde0588b0a6e70b1fa971a99eca439d0aa6 (patch) | |
tree | 9a9fb939858962ab7b49ca046606fc49acb27509 /app/controllers/projects/commit_controller.rb | |
parent | 6d3eea7b46d4b363b39a59e1fa17264de33d14d1 (diff) |
moved throttling into the controller. if we hit the throttling
threshhold, a message is shown indicating we didn't perform the search
Diffstat (limited to 'app/controllers/projects/commit_controller.rb')
-rw-r--r-- | app/controllers/projects/commit_controller.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 893763862ba..5b8a8159123 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -56,8 +56,11 @@ class Projects::CommitController < Projects::ApplicationController end def branches - @branches = @project.repository.branch_names_contains(commit.id, 1000) - @tags = @project.repository.tag_names_contains(commit.id, 1000) + # branch_names_contains/tag_names_contains can take a long time when there are thousands of + # branches/tags - each `git branch --contains xxx` request can consume a cpu core. + # so only do the query when there are a manageable number of branches/tags + @branches = @project.repository.branch_count > 1000 ? [:limit_exceeded] : @project.repository.branch_names_contains(commit.id) + @tags = @project.repository.tag_count > 1000 ? [:limit_exceeded] : @project.repository.tag_names_contains(commit.id) render layout: false end |