Skip to content

Instantly share code, notes, and snippets.

@carolyncole
Last active August 29, 2015 14:16
Show Gist options
  • Save carolyncole/d49de666d1a81c8228cb to your computer and use it in GitHub Desktop.
Save carolyncole/d49de666d1a81c8228cb to your computer and use it in GitHub Desktop.
How to get Git PR Stats

Ever wonder how long your PRs take to get merged... I did.

  1. Grab the data using api.github.com and save it to a file
  • note: I had to do this in a browser as curl did not get it correctly. (Modify projecthydra/sufia to be your repo) https://api.github.com/repos/projecthydra/sufia/pulls?per_page=100&state=closed
  1. Parse it in the ruby console The code below will give you the average PR close time in hours.
f = File.new("prs.json”)
json = f.read
parsed = JSON.parse(json)
parsed.reduce(0) {| sum, pr| puts "sum: #{sum}"; sum + (DateTime.parse(pr["closed_at"]).to_i - DateTime.parse( pr["created_at"]).to_i)/60.0}/ parsed.count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment