Created
August 21, 2013 19:37
-
-
Save caniszczyk/6299139 to your computer and use it in GitHub Desktop.
Gets some basic statistics about Apache Mesos using the GitHub API
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 | |
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