Pull Request をメンバごとにカウントするため、
GitHub APIを使ってみた。
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse('http://XXXXXXXX/api/v3/repositories')
json = Net::HTTP.get(uri)
result = JSON.parse(json)
puts 'repos, created_at, html_url, user.login'
pullreq = {}
result.each{|var|
repos = var['full_name']
page = 1
begin
reposUri = URI.parse("http://XXXXXXXX/api/v3/repos/#{repos}/pulls?state=all&per_page=100&page=#{page}")
reposJson = Net::HTTP.get(reposUri)
reposResult = JSON.parse(reposJson)
reposResult.each{|reposVar|
if reposVar['created_at'] > '2014-09'
puts "#{repos}, #{reposVar['created_at']}, #{reposVar['html_url']}, #{reposVar['user']['login']}"
pullreq["#{reposVar['user']['login']}"] = 0 unless pullreq.key?("#{reposVar['user']['login']}")
pullreq["#{reposVar['user']['login']}"] += 1
else
break
end
}
page += 1
end while page <= 10
}
puts ''
pullreq.sort{ |(k1,v1),(k2,v2)| v2<=>v1 }
.each{ |k,v| puts "#{k}:#{v}" }
参考
all public repositories
参考:list-all-public-repositories
list-pull-requests
感想
- GUIにてプルリクMAX(Num)を確認してとりあえず「page <= 10」とした。