Github API чрезвычайно медленный запрос с Octokit - PullRequest
0 голосов
/ 05 июля 2018

пытается запросить github api с помощью octokit, У меня есть следующая функция, которая занимает 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
...