[BUG] Repository health merge rate can exceed 100%

Đang mở
#4,083 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Dhruvdesai793 đang làm issue này rồi.

Từ ngày 3/12/2026.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
github, next.js, typescript

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
246
Fork
436
Merge trung bình
9 giờ 33 phút
Pull request đã merge (30 ngày)
213

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Priyanshu-byte-coder/devtrack

Tất cả issue của Priyanshu-byte-coder/devtrack

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.