Skip to content

Instantly share code, notes, and snippets.

@carmstrong
Created December 18, 2014 21:36
Show Gist options
  • Save carmstrong/bcca0f38262a5ba4a987 to your computer and use it in GitHub Desktop.
Save carmstrong/bcca0f38262a5ba4a987 to your computer and use it in GitHub Desktop.
Deis project activity by user
#!/usr/bin/env ruby
require 'csv'
require 'octokit'
date_since = ARGV.first
if date_since.nil? or date_since.empty?
date_since = '2013-07-22'
end
# ignore project maintainers
ignored_contributors = %w[bacongobbler carmstrong gabrtv mboersma coveralls deis-admin]
# make our GitHub calls here
client = Octokit::Client.new(:access_token => ENV['GITHUB_ACCESS_TOKEN'], :auto_paginate => true)
issues = client.search_issues("repo:deis/deis created:>#{date_since}", {:per_page => 10000})
comments = client.issues_comments("deis/deis", {:since => date_since, :per_page => 10000})
touchers = {}
issues.items.each do |issue|
author = issue.user.login.to_s
if not ignored_contributors.include?(author)
if touchers[author].nil?
touchers[author] = 1
else
touchers[author] = touchers[author]+1
end
end
end
comments.each do |c|
author = c.user.login
if not ignored_contributors.include?(author)
if touchers[author].nil?
touchers[author] = 1
else
touchers[author] = touchers[author]+1
end
end
end
CSV.open("users.csv", "wb") do |csv|
csv << ["id", "touches", "name", "company", "location", "email"]
touchers.each do |id, count|
user = client.user(id)
csv << [id, count, user.name, user.company, user.location, user.email]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment