[BUG] Repository health merge rate can exceed 100%

Open
#4,083 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Dhruvdesai793 is already working on this.

Since Dec 3, 2026.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
github, next.js, typescript

Research direction

Start with the GraphQL query and date filters in src/app/api/metrics/repo-health/route.ts, then read the existing score tests in test/repo-health-scoring.test.ts. Add a route test with older PRs merged during the window and PRs opened during it, as the issue describes. Done means the API computes the rate from a consistent cohort and returns a value from 0 to 1.

Written by the indexing model from the issue text.

Description

bug needs-triage
What happened?

Repository health divides PRs merged during the selected window by PRs opened during that window. Those are different cohorts: a PR opened earlier but merged now is included in the numerator and omitted from the denominator.

For example, if two older PRs merge during the window and one PR is opened but remains open, the API returns a merge rate of 2.0 (200%). This makes the displayed metric misleading and can overstate the health score.

Source: the GraphQL query fetches recent opened PRs and merged PRs separately (route query); the route filters them using different timestamps and divides mergedCount by opened.length (calculation). Expected: calculate the rate over a consistent PR cohort and keep the returned value within 0–1.

Steps to reproduce
  1. Use a repository with at least two PRs opened before the selected period that merge during it.
  2. Have one additional PR opened during the period that is still open.
  3. Sign in and load Dashboard → Repository Health for that repository.
  4. Inspect the response from GET /api/metrics/repo-health?days=30.
  5. The route can return prMergeRate: 2 (200%) because it counts the two older merged PRs over the one newly opened PR.
Where is it?

Dashboard overview

Where did you see it?

Local development

Browser and device

Not browser-specific; server-side API data.

Screenshots, console errors or logs

No screenshot or runtime log applies. This is based on the route's date filters and division; the example above is arithmetic from those inputs, not a live API capture. I did not run tests for this report to avoid using the shared checkout while another contributor is working. Existing test/repo-health-scoring.test.ts covers scorePrMergeRate inputs, including clamping values above 1, but does not test how the API builds the rate from PR dates. A route test should mix older PRs merged in-range with PRs opened in-range and assert a coherent rate.

Want to fix it?
  • I'd like to work on this. A maintainer will assign you; please don't start before that.
Dominant language
TypeScript
Stars
246
Forks
436
Avg merge
9h 33m
Merged PRs (30d)
213

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Priyanshu-byte-coder/devtrack

All issues in Priyanshu-byte-coder/devtrack

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.