Skip to content

Commit

Permalink
Small analyze_prs improvements
Browse files Browse the repository at this point in the history
Don't error out if num users provided is greater than
returned total.

Drop users with 0 total prs.

Always sort by both total and revup_total, order changing
depending on args. This way listing of users with the
same number in one will still be sorted in the other.

Print percents in a few places as well.
  • Loading branch information
jerry-skydio committed Mar 11, 2024
1 parent 0fc6b0e commit e124811
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions scripts/analyze_prs.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@
total_revup += 1
users[name][1] += 1

# Delete users from the list with 0 prs
for user in list(users.keys()):
if users[user][0] == 0:
del users[user]
args.num_users = min(args.num_users, len(users))

print("Total PRs: {}".format(total))
print("Total revup PRs: {}".format(total_revup))
print("Total revup PRs: {} ({:.1f}%)".format(total_revup, 100.0 * total_revup / total))
print(
"Top {} contributors by number of {}prs".format(
args.num_users, "revup " if args.sort_by_revup else ""
Expand All @@ -82,11 +88,18 @@
for user in users:
users_sorted.append((user, users[user][0], users[user][1]))

# Sort by revup prs and total prs. The arg sort_by_revup determines
# the order in which the sorts happen.
users_sorted.sort(key=lambda tup: tup[2 - args.sort_by_revup], reverse=True)
users_sorted.sort(key=lambda tup: tup[1 + args.sort_by_revup], reverse=True)

for i in range(args.num_users):
print(
"{}: {} with {} PRs and {} revup PRs".format(
i + 1, users_sorted[i][0], users_sorted[i][1], users_sorted[i][2]
"{}: {} with {} PRs and {} revup PRs ({:}%)".format(
i + 1,
users_sorted[i][0],
users_sorted[i][1],
users_sorted[i][2],
int(100.0 * users_sorted[i][2] / users_sorted[i][1]),
)
)

0 comments on commit e124811

Please sign in to comment.