Skip to content

Instantly share code, notes, and snippets.

@garethrees
Created November 12, 2021 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garethrees/3d87dc63f42439e769c5e3ee3f231b07 to your computer and use it in GitHub Desktop.
Save garethrees/3d87dc63f42439e769c5e3ee3f231b07 to your computer and use it in GitHub Desktop.
alaveteli_pull_requests.rb
#!/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