Skip to content

Instantly share code, notes, and snippets.

@danvk
Created November 10, 2014 15:47
Show Gist options
  • Save danvk/ddbc0b6c5c3b0e9a5e03 to your computer and use it in GitHub Desktop.
Save danvk/ddbc0b6c5c3b0e9a5e03 to your computer and use it in GitHub Desktop.
Date/Time Open PRs Open Issues
2014-11-04T20:11:31.611119 8 126
2014-11-10T10:46:55.208083 6 123
#!/usr/bin/env python
import requests
import sys
from datetime import datetime
REPO_ROOT = 'https://api.github.com/repos/danvk/dygraphs'
def depaginate(start_url):
# de-paginates issues list
results = []
url = start_url
while True:
sys.stderr.write('Requesting %s\n' % url)
response = requests.get(url)
results.extend(response.json())
try:
url = response.links['next']['url']
except KeyError:
break
return results
def run(output_path):
pulls = depaginate('%s/pulls' % REPO_ROOT)
issues = depaginate('%s/issues' % REPO_ROOT)
open(output_path, 'a').write('\t'.join([datetime.now().isoformat(), str(len(pulls)), str(len(issues))]) + '\n')
if __name__ == '__main__':
run('dygraphs.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment