Created
October 30, 2015 21:52
-
-
Save mchail/effbd3fe41c6291e5d89 to your computer and use it in GitHub Desktop.
find Jordan's last PR
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
require 'json' | |
require 'httparty' | |
class FindJordansPR | |
def auth | |
{ | |
username: :mchail, | |
password: ENV['pw'] | |
} | |
end | |
def get(path) | |
response = HTTParty.get("https://api.github.com/#{path}", basic_auth: auth) | |
JSON.parse(response.body) | |
end | |
def prs | |
all_prs = [] | |
["nowspots", "perfectaudience"].each do |org| | |
repos = get("orgs/#{org}/repos") | |
repo_names = repos.map do |repo| | |
repo["name"] | |
end | |
repo_names.each do |repo| | |
all_prs += get("repos/#{org}/#{repo}/pulls") | |
end | |
end | |
all_prs | |
end | |
def prs_by_name | |
prs.group_by do |pr| | |
pr["user"]["login"] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment