From 528f9cde0588b0a6e70b1fa971a99eca439d0aa6 Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Thu, 12 Oct 2017 15:31:43 +0200 Subject: moved throttling into the controller. if we hit the throttling threshhold, a message is shown indicating we didn't perform the search --- app/controllers/projects/commit_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'app/controllers/projects/commit_controller.rb') 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 -- cgit v1.2.1