[BUG] Repo analytics reports one pull request when a repo has none

Open
#4,084 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
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
github, nextjs, typescript

Research direction

Read src/app/api/metrics/repo-analytics/route.ts around lines 190–206, then inspect test/repo-analytics-validation.test.ts for route test patterns. Mock a successful empty pulls response without a Link header and check the returned total. Done means prActivity.total is 0 for an empty result while existing analytics behavior remains covered.

Written by the indexing model from the issue text.

Description

bug needs-triage
What happened?

Repo analytics reports one pull request for a repository with no pull requests. The route requests one page item, checks the pagination Link header, and falls back to 1 whenever the response is successful but has no rel=last link. GitHub's empty result has no Link header, so the empty case is reported as one.

Expected: return 0 when the successful response contains no pull requests.

Source: the request and fallback set totalPrs to 1 in this case; the Repo Analytics sheet displays that value.

Steps to reproduce
  1. Sign in and open Repo Analytics for a repository with no pull requests.
  2. Inspect GET /api/metrics/repo-analytics?repo=owner/repo.
  3. GitHub returns an empty pull-request list with no Link header.
  4. The route returns prActivity.total: 1, and the sheet displays one PR instead of zero.
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 a source-level reproduction from the successful empty-response branch; I did not make a live request to GitHub for a specific repository. I did not run tests for this report to avoid using the shared checkout while another contributor is working. Existing test/repo-analytics-validation.test.ts checks parameter validation and cache behavior, but does not assert the pull-request total for an empty result. A route regression test should mock an empty successful pulls response without a Link header and expect prActivity.total to be 0.

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.