Skip to content

Instantly share code, notes, and snippets.

@caniszczyk
Created August 21, 2013 19:37
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 caniszczyk/6299139 to your computer and use it in GitHub Desktop.
Save caniszczyk/6299139 to your computer and use it in GitHub Desktop.
Gets some basic statistics about Apache Mesos using the GitHub API
#!/usr/bin/env ruby
require 'octokit'
require 'csv'
client = Octokit::Client.new(auto_traversal: true, per_page: 500);
puts client.ratelimit_remaining
CSV.open("stats.csv", "wb") do |csv|
repo = client.repo("apache/mesos")
stats = client.commit_activity_stats("apache/mesos")
total_commits_per_year = 0
unless stats.nil?
i = 0
commits_last_three_months = 0;
stats.each do |h|
total_commits_per_year += h["total"]
if i>40 # last three months
commits_last_three_months += h["total"]
end
i+=1
end
end
contributors = client.contributors(repo.full_name)
csv << [repo.full_name, repo.pushed_at, repo.created_at, contributors.size, repo.forks, repo.watchers, total_commits_per_year, commits_last_three_months]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment