Skip to content

Instantly share code, notes, and snippets.

@rouault
Created March 25, 2023 18:36
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 rouault/0fbd37f59b8e93ae63761468a5600262 to your computer and use it in GitHub Desktop.
Save rouault/0fbd37f59b8e93ae63761468a5600262 to your computer and use it in GitHub Desktop.
from github import Github
from datetime import datetime, timedelta
# Create a Github instance using an access token
g = Github("PUT_HERE_YOUR_TOKEN")
repo = g.get_repo("OSGeo/gdal")
start_date = datetime(2021, 8, 1)
pulls = repo.get_pulls(state="closed", sort="created", direction="desc")
comment_times = []
count_pr = 0
for pull in pulls:
if pull.user.login in ('rouault', 'github-actions[bot]'):
continue
if pull.created_at < start_date:
break
print(pull, pull.user.login)
count_pr += 1
comment_time = None
for comment in pull.get_issue_comments():
if comment.user.login == "rouault":
comment_date = comment.created_at
open_date = pull.created_at
comment_time = comment_date - open_date
break # Only consider the first comment by rouault
for comment in pull.get_review_comments():
if comment.user.login == "rouault":
comment_date = comment.created_at
open_date = pull.created_at
l_comment_time = comment_date - open_date
if comment_time is None or l_comment_time < comment_time:
comment_time = l_comment_time
break # Only consider the first comment by rouault
if comment_time:
print('comment_time', comment_time)
elif pull.merged and pull.merged_by.login == "rouault":
open_date = pull.created_at
merge_date = pull.merged_at
comment_time = merge_date - open_date
print('merge_time', comment_time)
if comment_time:
comment_times.append(comment_time)
total = timedelta(days=0)
max_time = timedelta(days=0)
comment_times = sorted(comment_times)
for t in comment_times:
if t > max_time:
max_time = t
total += t
average_comment_time = total / len(comment_times)
print(f"Average comment/merge time: {average_comment_time}")
median = comment_times[len(comment_times)//2]
print(f"Median comment/merge time: {median}")
print(f"max_time time: {max_time}")
print(f"count_pr: {count_pr}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment