尝试使用octokit查询github API, 我有以下需要3-4分钟的功能,有人为什么会花这么慢的时间看到一个明显的问题吗? 通过遍历组织中的每个存储库,然后从那里检查存储库的主要贡献者,然后进行排序,我试图找到组织中的主要贡献者。
def get_top_internal(client)
repos = client.org_repos(params[:org])
contributor_count_hash = Hash.new(0)
contributors = []
repos.each do |repo|
contributors = client.contributors(repo.full_name,anon=true,per_page:10)
contributors.each do |contributor|
contributor_count_hash[contributor.login] += contributor.contributions
end
end
sorted = contributor_count_hash.sort_by {|arr| arr[1]}
sorted = sorted.slice!(-5..-1)
user_names = sorted.map {|arr| arr[0]}
debugger
return_array = contributors.select {|user| user_names.include? user[:login]}
end