Skip to content

Instantly share code, notes, and snippets.

@jbarr21
Created July 13, 2018 04:09
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 jbarr21/133c350bfc35944f861e316c948c2e5f to your computer and use it in GitHub Desktop.
Save jbarr21/133c350bfc35944f861e316c948c2e5f to your computer and use it in GitHub Desktop.
Phabricator Diff Stats
from phabricator import Phabricator
username = 'USERNAME'
ph = Phabricator()
my_phid = ph.user.whoami().phid
phid = ph.user.find(aliases=[username])[username]
def diffs_search(constraints, after=None):
diffs = []
while True:
resp = ph.differential.revision.search(constraints=constraints, attachments={'reviewers': True}, after=after)
diffs += resp.data
after = resp.cursor['after']
if after is None or after == '':
break
return diffs
def is_reviewed_by(diff, reviewer_phid):
reviews = diff['attachments']['reviewers']['reviewers']
return len([review for review in reviews if review['reviewerPHID'] == reviewer_phid and review['status'] == 'accepted']) > 0
def main():
diffs_authored = diffs_search({'authorPHIDs': [phid]})
diffs_reviewed = diffs_search({'reviewerPHIDs': [phid]})
reviews = [diff for diff in diffs_reviewed if is_reviewed_by(diff, phid)]
print 'username:', username
print 'authored:', len(diffs_authored)
print 'reviews:', len(diffs_reviewed)
print 'reviews accepted:', len(reviews)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment