Commit 216a4823 authored by Sean McGivern's avatar Sean McGivern

Speed up suggested approvers

Instead of performing `git log` for each file that's changed, do it for
all files at once. This stops git having to load large packfiles once
for each file in an MR.

This is always a suggestion, so the change in behaviour should be
fine. Increase the number of commits counted by squaring it, to allow
for the fewer calls to `git log`.
parent da45e0cb
module Gitlab
class AuthorityAnalyzer
COMMITS_TO_CONSIDER = 5
COMMITS_TO_CONSIDER = 25
def initialize(merge_request)
@merge_request = merge_request
......@@ -19,14 +19,12 @@ module Gitlab
def involved_users
@repo = @merge_request.target_project.repository
list_of_involved_files.each do |path|
@repo.commits(@merge_request.target_branch, path: path, limit: COMMITS_TO_CONSIDER).each do |commit|
@repo.commits(@merge_request.target_branch, path: list_of_involved_files, limit: COMMITS_TO_CONSIDER).each do |commit|
if commit.author && commit.author != @merge_request.author
@users[commit.author] += 1
end
end
end
end
def list_of_involved_files
diffable = [@merge_request.compare, @merge_request.merge_request_diff].compact
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment