From e145f46a930b932ebc3ff70f75d69f45573cbad9 Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Tue, 30 Sep 2014 11:56:48 +0300
Subject: [PATCH] Fix contributors api

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
---
 app/models/repository.rb               | 10 ++++------
 spec/requests/api/repositories_spec.rb |  4 ++--
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/app/models/repository.rb b/app/models/repository.rb
index ed220ae2e..082086d8e 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -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
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb
index a339dbfe9..6e54839b6 100644
--- a/spec/requests/api/repositories_spec.rb
+++ b/spec/requests/api/repositories_spec.rb
@@ -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
-- 
2.30.9