Skip to content

Instantly share code, notes, and snippets.

@indirect
Last active December 2, 2015 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indirect/93f9a2e759fd823ae8ed to your computer and use it in GitHub Desktop.
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.
#!/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