查询每个项目的各个成员中的提交贡献次数
This commit is contained in:
parent
87be2dd7fe
commit
0324282641
|
@ -85,5 +85,12 @@ class Gitlab::Client
|
|||
get("/projects/#{project}/repository/commits/#{sha}/diff")
|
||||
end
|
||||
alias_method :repo_commit_diff, :commit_diff
|
||||
|
||||
#Get the commits count of each contributor in a project
|
||||
#@param [Integer] project the ID fo a project.
|
||||
# @return [Gitlab::ObjectifiedHash]
|
||||
def contributors(project)
|
||||
get("/projects/#{project}/repository/contributors")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
#coding=utf-8
|
||||
|
||||
namespace :gitlab do
|
||||
desc "sync gitlab's users which lost in last sync"
|
||||
task :query => :environment do
|
||||
g = Gitlab.client
|
||||
projects = Project.all
|
||||
users_email = User.find_by_sql("select mail from users where mail != '' ")
|
||||
projects.each do|project|
|
||||
gpid = project.gpid
|
||||
begin
|
||||
contributors_list = g.contributors(gpid)
|
||||
rescue
|
||||
next
|
||||
end
|
||||
puts "project_id #{project.id}"
|
||||
contributors_list.each do|contributor|
|
||||
if users_email.include?(contributor.email)
|
||||
contributors_list.delete(contributor)
|
||||
end
|
||||
end
|
||||
|
||||
contributors_list.each do|contributor|
|
||||
puts "name #{contributor.name}"
|
||||
puts "email #{contributor.email}"
|
||||
puts "commits_count #{contributor.commits}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue