Last active
December 2, 2015 18:52
-
-
Save indirect/93f9a2e759fd823ae8ed to your computer and use it in GitHub Desktop.
Print the top committers and commenters from a repo for the last year.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
api_token = "xxx" | |
org_name, repo_name = ARGV.first.split("/") | |
module Enumerable | |
def histogram(&block) | |
h = Hash.new(0) | |
each do |entry| | |
key = block_given? ? yield(entry) : entry | |
h[key] += 1 | |
end | |
h | |
end | |
end | |
require "github_api" | |
c = Github::Client::Issues::Comments.new oauth_token: api_token | |
names = [] | |
last_year = (Date.today-365).to_time.iso8601 | |
res = c.all(org_name, repo_name, since: last_year, per_page: 100) | |
res.each_page{|page| names += page.map{|cm| (cm["user"] || {})["login"] } } | |
names.histogram.reject{|n,c| c < 20}.sort_by(&:last).reverse.each{|n,c| puts "#{n} (#{c} comments)" } | |
c = Github::Client::Repos::Commits.new oauth_token: api_token | |
names = [] | |
last_year = (Date.today-365).to_time.iso8601 | |
res = c.all(org_name, repo_name, since: last_year, per_page: 100) | |
res.each_page{|page| names += page.map{|cm| (cm["author"] || {})["login"] } } | |
names.histogram.reject{|n,c| c < 5}.sort_by(&:last).reverse.each{|n,c| puts "#{n} (#{c} commits)" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment