Commit e145f46a authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix contributors api

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 57c0d9ec
......@@ -250,20 +250,18 @@ class Repository
end
def contributors
log = graph_log.group_by { |i| i[:author_email] }
commits = self.commits(nil, nil, 2000, 0, true)
log.map do |email, contributions|
commits.group_by(&:author_email).map do |email, commits|
contributor = Gitlab::Contributor.new
contributor.email = email
contributions.each do |contribution|
commits.each do |commit|
if contributor.name.blank?
contributor.name = contribution[:author_name]
contributor.name = commit.author_name
end
contributor.commits += 1
contributor.additions += contribution[:additions] || 0
contributor.deletions += contribution[:deletions] || 0
end
contributor
......
......@@ -224,8 +224,8 @@ describe API::API, api: true do
contributor['email'].should == 'dmitriy.zaporozhets@gmail.com'
contributor['name'].should == 'Dmitriy Zaporozhets'
contributor['commits'].should == 13
contributor['additions'].should == 4081
contributor['deletions'].should == 29
contributor['additions'].should == 0
contributor['deletions'].should == 0
end
end
end
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