Created
January 7, 2019 23:26
-
-
Save cv/41369238837d9cc547ae2f2dfc4d04a0 to your computer and use it in GitHub Desktop.
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 "bundler/inline" | |
ORG=(ARGV.length == 1 && ARGV[0]) or raise "Usage: pr-queue.rb <org-name>" | |
gemfile do | |
source "https://rubygems.org" | |
gem "octokit" | |
gem "pry" | |
end | |
puts "# Gems installed and loaded" | |
client = Octokit::Client.new( | |
access_token: ENV.fetch("GITHUB_TOKEN"), | |
auto_paginate: true | |
) | |
puts "# Github client created" | |
repo_names = client.org_repos("#{ORG}").map {|repo| repo.name }.sort | |
puts "# Found #{repo_names.length} repos" | |
repo_names.inject({}) do |a,e| | |
pulls = client.pulls("#{ORG}/#{e}", state: "open") | |
days_outstanding = pulls.map {|pr| (Time.now.to_date.mjd - pr.created_at.to_date.mjd) }.sum | |
a[e] = [pulls.length, days_outstanding] if days_outstanding > 0 | |
a | |
end.sort_by {|k, v| v }.each do |k, v| | |
puts "#{k}, #{v[0]}, #{v[1]}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment