Skip to content

Commit

Permalink
Switch GitHub PR throughput to use merged, not closed
Browse files Browse the repository at this point in the history
  • Loading branch information
ghickman committed Nov 21, 2023
1 parent e1cb148 commit b31d3ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions metrics/github/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def prs_open_in_range(org, start, end):
return list(_iter_pull_requests(org, date_range))


def prs_closed_on_date(org, date):
query = f"closed:{date}"
def prs_merged_on_date(org, date):
query = f"merged:{date}"

return list(_iter_pull_requests(org, query))

Expand Down
9 changes: 5 additions & 4 deletions metrics/github/backfill.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def get_prs(db):
SELECT
date(pull_requests.created_at) as created,
date(pull_requests.closed_at) as closed,
date(pull_requests.merged_at) as merged,
authors.login as author,
repos.name as repo,
owners.login as org
Expand Down Expand Up @@ -108,11 +109,11 @@ def pr_throughput(prs, org):
log.info("%s | %s | Processing %s opened PRs", day, org, len(opened_prs))
process_prs(writer, opened_prs, day, name="prs_opened")

closed_prs = [
pr for pr in prs if pr["closed"] and date_from_iso(pr["closed"]) == day
merged_prs = [
pr for pr in prs if pr["merged"] and date_from_iso(pr["merged"]) == day
]
log.info("%s | %s | Processing %s closed PRs", day, org, len(closed_prs))
process_prs(writer, closed_prs, day, name="prs_closed")
log.info("%s | %s | Processing %s merged PRs", day, org, len(merged_prs))
process_prs(writer, merged_prs, day, name="prs_merged")


@click.command()
Expand Down
6 changes: 3 additions & 3 deletions metrics/github/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def pr_throughput(ctx, org, date):
log.info("%s | %s | Processing %s opened PRs", date, org, len(opened_prs))
process_prs(writer, opened_prs, date, name="prs_opened")

closed_prs = api.prs_closed_on_date(org, date)
log.info("%s | %s | Processing %s closed PRs", date, org, len(closed_prs))
process_prs(writer, closed_prs, date, name="prs_closed")
merged_prs = api.prs_merged_on_date(org, date)
log.info("%s | %s | Processing %s merged PRs", date, org, len(merged_prs))
process_prs(writer, merged_prs, date, name="prs_merged")


github.add_command(backfill)

0 comments on commit b31d3ba

Please sign in to comment.