Skip to content

feat: Add PR open time distribution histogram [issue: #167]Feat/pr open time histogram#392

Open
abdullahxyz85 wants to merge 8 commits into
Priyanshu-byte-coder:mainfrom
abdullahxyz85:feat/pr-open-time-histogram
Open

feat: Add PR open time distribution histogram [issue: #167]Feat/pr open time histogram#392
abdullahxyz85 wants to merge 8 commits into
Priyanshu-byte-coder:mainfrom
abdullahxyz85:feat/pr-open-time-histogram

Conversation

@abdullahxyz85
Copy link
Copy Markdown
Contributor

Summary [Issue: #167 ]

Adds a histogram showing how long PRs stay open before being merged, broken into time buckets to reveal code review velocity patterns.

What's Changed

  • New horizontal bar chart in PRMetrics component showing PR open time distribution
  • 4 time buckets: < 1h, 1-24h, 1-7d, > 7d
  • Uses recharts BarChart with responsive sizing
  • Interactive tooltips showing exact PR count per bucket
  • Respects existing 30-day range filter (ready for future range selection)
  • All styling uses CSS variables for theme consistency

Implementation Details

  • Modified /api/metrics/prs/route.ts to calculate and return time distribution data
  • Updated PRMetrics.tsx to render histogram below existing stats
  • Added TypeScript interfaces for proper type safety
  • Maintains backward compatibility with existing metrics

Visual Preview

image --- image --- image

Acceptance Criteria Met [issue: #167 ]

  • ✅ New chart in PR Analytics widget
  • ✅ 4 time buckets with intuitive labels
  • ✅ Horizontal bar chart using recharts
  • ✅ Data from existing /api/metrics/prs endpoint
  • ✅ Respects 30-day range
  • ✅ Uses CSS variables for colors
  • ✅ Tooltip shows exact count on hover

@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

@abdullahxyz85 is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@abdullahxyz85
Copy link
Copy Markdown
Contributor Author

@Priyanshu-byte-coder check it now, I close the older PR and create new PRs by spliting from each others, please review and merge and make sure to add the labels, gssoc:approved and level.

Copy link
Copy Markdown
Owner

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

Choose a reason for hiding this comment

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

Three bugs in prs/route.ts:

1. Duplicate fetchPRMetrics function definition
The diff adds a second async function fetchPRMetrics(token, days) above the original async function fetchPRMetrics(token) that still exists in the file. TypeScript will throw a duplicate identifier error. Remove the old fetchPRMetrics signature and replace it with the new days parameter version. This is a merge conflict artifact.

2. Duplicate mergeRate in return object

return {
  ...
  mergeRate: data.total_count > 0 ? merged / data.total_count : 0,  // ← first (wrong)
  timeDistribution,
  mergeRate: sampleTotal > 0 ? merged / sampleTotal : 0,            // ← duplicate
};

Duplicate property — remove the first mergeRate line. The sampleTotal formula is correct.

3. Time distribution uses closedPRs + closed_at — should use mergedPRs + merged_at
The buckets loop over closedPRs (PRs closed without merging) and use closed_at. This mixes rejected PRs into the 'time to open' distribution. The chart should show time-to-merge only — loop over mergedPRs and use merged_at.

@abdullahxyz85
Copy link
Copy Markdown
Contributor Author

abdullahxyz85 commented May 19, 2026

@Priyanshu-byte-coder Done! Please make sure to add the label: gssoc:approved and level:adavanced.

Copy link
Copy Markdown
Owner

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

Choose a reason for hiding this comment

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

  1. route.ts will not compile — unresolved merge conflict artifacts: duplicate formatPRMetrics declarations, two result bindings in same scope, unclosed if block. Fully rebase on main and resubmit. 2. Cache bypassed — fetchPRMetrics called directly in all branches, skipping fetchCachedPRMetrics. Restore caching. 3. cursor={{ fill: var(--accent)/10 }} — invalid Recharts prop value. Use rgba() instead.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature labels May 20, 2026
@abdullahxyz85
Copy link
Copy Markdown
Contributor Author

@Priyanshu-byte-coder Conflicts are resolved and fix all the things , please review and merge it and add label: gssoc:approved and level

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

Labels

gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants