From 5606eea329fa98731f0fa991a382a62245e41a09 Mon Sep 17 00:00:00 2001 From: webbrain-one <295484252+webbrain-one@users.noreply.github.com> Date: Wed, 5 Aug 2026 08:24:04 +0300 Subject: [PATCH] Include user contributions from non-owned repositories Update the GitHub client to fetch repositories where the user has contributed, regardless of ownership. Fixes #2 --- app/services/github_client.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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|