Skip to content

Instantly share code, notes, and snippets.

Created Jan 7, 2019
What would you like to do?
#!/usr/bin/env ruby
require "bundler/inline"
ORG=(ARGV.length == 1 && ARGV[0]) or raise "Usage: pr-queue.rb <org-name>"
gemfile do
source ""
gem "octokit"
gem "pry"
puts "# Gems installed and loaded"
client =
access_token: ENV.fetch("GITHUB_TOKEN"),
auto_paginate: true
puts "# Github client created"
repo_names = client.org_repos("#{ORG}").map {|repo| }.sort
puts "# Found #{repo_names.length} repos"
repo_names.inject({}) do |a,e|
pulls = client.pulls("#{ORG}/#{e}", state: "open")
days_outstanding = {|pr| ( - pr.created_at.to_date.mjd) }.sum
a[e] = [pulls.length, days_outstanding] if days_outstanding > 0
end.sort_by {|k, v| v }.each do |k, v|
puts "#{k}, #{v[0]}, #{v[1]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment