Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.