Skip to content

feat(prs): show PRs reviewed and review participation rate - #3639

Merged
Priyanshu-byte-coder merged 1 commit into
Priyanshu-byte-coder:mainfrom
officialasishkumar:feat/pr-review-participation
Nov 16, 2026
Merged

Priyanshu-byte-coder merged 1 commit into
Priyanshu-byte-coder:mainfrom
officialasishkumar:feat/pr-review-participation

Conversation

@officialasishkumar

Copy link
Copy Markdown
Contributor

Summary

Adds the review participation metric from #191 to the Reviews you gave panel: the number of distinct PRs by other people you reviewed in the range, and that number as a percentage of the PRs you opened. Until now the panel only counted review submissions, so three reviews on one PR looked like three PRs, and reviews on your own PRs counted too.

Closes #191


Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📝 Documentation update
  • ♻️ Refactor / code cleanup (no functional change)
  • ⚡ Performance improvement
  • 🔒 Security fix
  • 🧪 Tests only

What Changed

  • src/lib/pull-requests.ts: the existing pullRequestReviewContributions selection also fetches pullRequest { url author { login } }. This is the same single GraphQL request, so there are no extra API calls (the issue suggested a reviewed-by: search; the contributions data already covers it and matches the selected range exactly). summarizePullRequests adds three fields to reviews:
    • prsReviewed: distinct reviewed PRs, deduped by URL across reviews and linked accounts. PRs authored by the signed-in login or any linked account are excluded, compared case-insensitively.
    • participationRate: prsReviewed / opened for the range, or null when no PRs were opened.
    • sampled: true when you gave more reviews than the 100 nodes one request returns, so the count is a lower bound.
  • src/app/api/metrics/prs/route.ts: cache key v: 2 → v: 3 so cached payloads without the new fields aren't served.
  • src/components/PRMetrics.tsx: a PRs reviewed figure next to "reviews submitted", with the tooltip from the issue ("PRs where you left a review comment or approval"), and a line like 150% review participation. A sampled count shows as 80+ with "(latest 100 reviews)". When no PRs were opened in the range, the line says so instead of showing a rate. It follows the 7d / 30d / 90d range like the rest of the panel.
  • Tests: test/pull-requests.test.ts covers repeat reviews on one PR, reviews on your own and linked-account PRs, the same PR seen from two accounts, null PR authors (deleted accounts), no PRs opened, and sampling. The new test/components/PRMetrics.test.tsx covers the rendered count, the rate, the sampled +, and the no-PRs message. All of these fail without the change.
  • The e2e mocks (e2e/helpers/dashboard-mocks.js, e2e/dashboard.spec.ts) and the /api/metrics/prs row in docs/api.md include the new fields.

How to Test

  1. pnpm vitest run test/pull-requests.test.ts test/components/PRMetrics.test.tsx
  2. Sign in with an account that has reviewed other people's PRs, open the dashboard's pull request view, and switch between 7d / 30d / 90d.
  3. Pick a range where you opened no PRs.

Expected result: The panel shows how many distinct PRs you reviewed and the percentage compared with the PRs you opened, and both change with the range. With no PRs opened, it shows the explanatory line instead of a rate.


Checklist

  • Linked the related issue above
  • Self-reviewed my own diff
  • No unnecessary console.log, debug code, or commented-out blocks
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Added or updated tests where applicable
  • Updated documentation / comments if behavior changed

Accessibility (UI changes only)

  • Keyboard navigation works correctly (no new interactive elements)
  • Color contrast meets WCAG AA standard (reuses the panel's existing text colours)
  • ARIA labels / roles added where needed
  • Tested on mobile / responsive layout

Additional Context

  • Ran the new selection against the live GitHub GraphQL API and fed the response through summarizePullRequests: the counts matched the distinct PR URLs in the response.
  • The full Vitest suite passes locally (206 files, 2669 tests), along with tsc --noEmit, ESLint, and Prettier on the changed files.

The "Reviews you gave" panel counted review submissions, so three
reviews on one PR looked like three PRs and reviews left on your own PRs
counted as participation. It had no way to compare how much you review
with how much you ship, which is what Priyanshu-byte-coder#191 asks for.

- src/lib/pull-requests.ts: the review contributions query now also
  fetches each reviewed PR's URL and author. summarizePullRequests adds
  reviews.prsReviewed (distinct PRs by someone else, deduped across
  linked accounts, own and linked-account PRs excluded),
  reviews.participationRate (PRs reviewed / PRs opened in the range,
  null when none were opened) and reviews.sampled (more reviews than the
  100 one request returns, so the count is a lower bound).
- src/app/api/metrics/prs/route.ts: bump the cache key version so cached
  payloads without the new fields are not served.
- src/components/PRMetrics.tsx: show "PRs reviewed" next to reviews
  submitted, with the tooltip from the issue, and the participation rate
  as a percentage. A sampled count shows as "80+", and the rate line
  explains itself when no PRs were opened in the range.
- Tests: unit tests for dedupe, self-review exclusion, linked accounts,
  null authors, no PRs opened and sampling; a component test for the
  panel. The e2e mocks and docs/api.md describe the new fields.

Closes Priyanshu-byte-coder#191
@github-actions github-actions Bot added type:devops GSSoC type bonus: devops (+15 pts) type:docs GSSoC type bonus: documentation (+5 pts) type:feature GSSoC type bonus: new feature type:testing GSSoC type bonus: tests (+10 pts) labels Nov 15, 2026

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Priyanshu-byte-coder
Priyanshu-byte-coder merged commit 373aa77 into Priyanshu-byte-coder:main Nov 16, 2026
14 checks passed
@github-actions

Copy link
Copy Markdown

🎉 Merged! Thanks for contributing to DevTrack.

If the project has been useful to you, a ⭐ star on the repo is the easiest way to support it — it helps DevTrack get discovered by more developers.

Keep an eye on open issues for your next contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:devops GSSoC type bonus: devops (+15 pts) type:docs GSSoC type bonus: documentation (+5 pts) type:feature GSSoC type bonus: new feature type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Add PR review participation rate metric

2 participants