Skip to content

Refactor PR/BEP README tables: split combined cells into sortable columns + fix counting of authors - #16

Open
yarikoptic wants to merge 2 commits into
mainfrom
claude/bids-schema-pr-display-ds2fna
Open

Refactor PR/BEP README tables: split combined cells into sortable columns + fix counting of authors#16
yarikoptic wants to merge 2 commits into
mainfrom
claude/bids-schema-pr-display-ds2fna

Conversation

@yarikoptic

Copy link
Copy Markdown
Collaborator

Original PR was in my fork

which would have all the gory AI sloppy descriptions

claude added 2 commits August 31, 2026 10:23
…view components

Three changes to the generated `PRs/README.md` / `BEPs/README.md` tables:

1. Counts and dates now live in separate columns. `47 (2020-01-16 →
   2026-05-08)` was a single cell, so GitHub's column sort ordered it as
   a string — useless for every ordering one actually wants. It is now
   `Comments` / `First comment` / `Last comment`, and the old `Commit
   window` cell is `Commits` / `First commit` / `Last commit` (the commit
   count was not previously surfaced at all).

2. `format_reviews` omits zero-valued components: `1✅/0❌/27💬` renders
   as `1✅/27💬`. All-zero still renders as `0`.

3. New `Created` column (PR open date, from the already-collected
   `stats.pr_created_at`). This explains the otherwise baffling rows
   where the first comment predates the first commit: on a long-lived PR
   a force-push replaces the branch's commits, and GitHub only reports
   what survived. PR #105 is the live example — opened 2018-12-12,
   earliest surviving commit authored 2022-04-22. Nothing recoverable
   sits in the commit metadata for those lost commits (the collector
   already prefers `authoredDate` over `committedDate`, which is what
   survives a plain rebase), so the fix is to show the PR's real start
   date alongside. Both READMEs gained a note saying so.

The PR table's existing `Last commit` column (the built SHA) is renamed
`Head` to free the name for the commit-window date.

`format_stats_cells` now returns the keys in `STATS_CELL_KEYS`;
`format_activity_span` and `format_date_window` are dropped as their only
callers are gone. Tests updated and extended: review-component dropping,
`format_count`, header/column-order lock, and a PR #105 regression guard.
`authors_count` was wrong in two independent ways, which is why BEP032 /
PR #2307 showed 2 contributors.

**Stale.** It is `git shortlog -sn | wc -l` run once when the *schema* is
built, and nothing ever refreshes it. PR #2307's value was recorded on
2026-05-12 at commit f6b65e5f, when the branch genuinely had two authors;
the branch has since grown to 24 commits and five people, but no schema
rebuild means no recount. Every other number in that row is refreshed
twice daily by `collect prs`, so the column silently disagreed with its
neighbours.

**Miscounted even when fresh.** `git shortlog` reads only the author
field and groups by display name. On PR #2307 that both misses the people
who merely landed patches and splits "Chris Markiewicz" /
"Christopher J. Markiewicz" — one address, markiewicz@stanford.edu — into
two contributors. Fresh shortlog gives 6; the real count is 5.

So contributor counting moves into the stats collector, where it is
recomputed every cycle:

- The commits GraphQL query now fetches `author`/`committer` as
  `{name, email, user{login}}` rather than just the author's login.
- New `resolve_contributors()` derives `stats.contributors`
  `{count, authors, committers, by_identity}`. Both roles count. Identity
  is keyed on GitHub login when GitHub resolved the commit email to an
  account and on the lowercased email otherwise, and a second pass folds
  bare-email identities into a login when another commit tied that
  address to an account — so one person split across resolved and
  unresolved commits still counts once. GitHub's web-flow identity
  (`noreply@github.com`) and `[bot]` logins are dropped; per-user
  `…@users.noreply.github.com` addresses are real people and kept.

`tools/inject-schema-pr` still writes `authors_count` at build time, but
via a new `count_contributors` helper using mailmap-canonical `%aE`/`%cE`
rather than shortlog, so the seed is right too (5 for PR #2307). It is
now explicitly a seed: `format_contributors` prefers
`stats.contributors.count` and falls back to it only when stats are
absent.

Columns: `Authors` is renamed `# Authors` and a `# Commenters` column is
added, counting distinct accounts in `stats.comments.by_author`.

Note that `# Authors` keeps rendering the old seed value until the next
`collect prs` cycle populates `stats.contributors` — the collector needs
an authenticated `gh`, which this checkout has no access to.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants