Created
July 13, 2018 04:09
-
-
Save jbarr21/133c350bfc35944f861e316c948c2e5f to your computer and use it in GitHub Desktop.
Phabricator Diff Stats
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
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