Skip to content
Snippets Groups Projects
Verified Commit 0d0adf9c authored by Heinrich Lee Yu's avatar Heinrich Lee Yu
Browse files

Improve performance of finding related branches

Filters the branches in Redis instead of loading all branches and
filtering in Ruby

Changelog: performance
parent 80ac35c7
No related branches found
No related tags found
1 merge request!91676Improve performance of finding related branches
......@@ -36,8 +36,10 @@ def branches_with_merge_request_for(issue)
end
def branches_with_iid_of(issue)
project.repository.branch_names.select do |branch|
branch =~ /\A#{issue.iid}-(?!\d+-stable)/i
branch_name_regex = /\A#{issue.iid}-(?!\d+-stable)/i
project.repository.search_branch_names("#{issue.iid}-*").select do |branch|
branch.match?(branch_name_regex)
end
end
end
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Issues::RelatedBranchesService do
RSpec.describe Issues::RelatedBranchesService, :clean_gitlab_redis_cache do
let_it_be(:developer) { create(:user) }
let_it_be(:issue) { create(:issue) }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment