diff --git a/app/services/github_client.rb b/app/services/github_client.rb index 7b501b0..cc295ff 100644 --- a/app/services/github_client.rb +++ b/app/services/github_client.rb @@ -10,13 +10,13 @@ def find_user_info(input_user) # Returns [ [array-of-languages-and-info] , number-of-total-stars ] def find_repos_info(input_user) - base_url = "https://api.github.com/users/#{input_user}/repos?access_token=" - user_repos = JSON.parse Curl::Easy.perform(base_url + ENV['github_token']) { |curl| curl.headers['User-Agent'] = 'github-languages' }.body_str + base_url = "https://api.github.com/users/#{input_user}/contributions?access_token=" + user_contributions = JSON.parse Curl::Easy.perform(base_url + ENV['github_token']) { |curl| curl.headers['User-Agent'] = 'github-languages' }.body_str repos_info = [] user_lang = {} total_stars = 0 total_bytes = 0 - user_repos.delete_if { |repo| repo['fork'] == true }.each do |repo| + user_contributions.map { |c| c['repository'] }.compact.uniq { |r| r['id'] }.each do |repo| total_stars += repo['stargazers_count'] repo_lang = JSON.parse Curl::Easy.perform("#{repo['languages_url']}?access_token=" + ENV['github_token']) { |curl| curl.headers['User-Agent'] = 'github-languages' }.body_str repo_lang.each do |lang, bytes|