mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-13 14:46:05 +10:00
Fix contributors api
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user