Created
November 12, 2021 14:50
-
-
Save garethrees/3d87dc63f42439e769c5e3ee3f231b07 to your computer and use it in GitHub Desktop.
alaveteli_pull_requests.rb
This file contains hidden or 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 'pp' | |
require 'csv' | |
GITHUB_TOKEN = ENV['GITHUB_TOKEN'].freeze | |
SINCE=ARGV[0].freeze | |
client = Octokit::Client.new(access_token: GITHUB_TOKEN) | |
client.auto_paginate = true | |
all_pulls = client.pull_requests('mysociety/alaveteli', state: 'closed') | |
pulls = all_pulls.select do |pull| | |
pull.merged_at && pull.merged_at >= Time.parse(SINCE) | |
end | |
data = {} | |
data = pulls.map do |pull| | |
title = pull.title | |
url = pull.html_url | |
author = pull.user.login | |
date = pull.merged_at.strftime('%b %Y') | |
[title, url, date, author] | |
end | |
csv_string = CSV.generate do |csv| | |
csv << %w(title url date author) | |
data.each do |pull| | |
csv << pull | |
end | |
end | |
puts csv_string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment