Skip to content

feat: add review cycle time metric with weekly trend chart and slowes…#357

Open
YuktiNandwana wants to merge 5 commits into
Priyanshu-byte-coder:mainfrom
YuktiNandwana:feat/review-cycle-time
Open

feat: add review cycle time metric with weekly trend chart and slowes…#357
YuktiNandwana wants to merge 5 commits into
Priyanshu-byte-coder:mainfrom
YuktiNandwana:feat/review-cycle-time

Conversation

@YuktiNandwana
Copy link
Copy Markdown

Summary

Added review cycle time metric to PR Analytics — tracks how long PRs sit before getting their first review (DORA metric).

Closes #255

Type of Change

  • New feature

Changes Made

  • GitHub GraphQL query to fetch PR reviews with submittedAt
  • Compute first_review_at - created_at per PR
  • Filter: only PRs where user is NOT the author + last 90 days
  • Added avgCycleTime stat card in PRMetrics component
  • Weekly trend chart using recharts (LineChart)
  • Top 3 slowest repos highlighted

How to Test

  1. Login to DevTrack with GitHub
  2. Navigate to PR Analytics section
  3. Verify "Avg Cycle Time" stat card appears
  4. Verify weekly trend chart renders
  5. Verify slowest repos section shows

Checklist

  • Linked issue in summary
  • No TypeScript errors
  • Self-reviewed the diff

@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

@YuktiNandwana 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.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Thanks for your first PR on DevTrack! 🎉

A maintainer will review it within 48 hours. While you wait:

  • Make sure CI is passing (type-check + lint)
  • Double-check the PR description is filled out and the issue is linked
  • Feel free to ask questions in Discussions if you need help

@YuktiNandwana
Copy link
Copy Markdown
Author

Hi @Priyanshu-byte-coder! I've resolved the merge conflicts with upstream/main. PR is ready for review

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

Good idea, but several issues block merge:

1. Reverts the merged PR #197 fix (critical)

PR #197 was merged specifically to fix merged vs closed counting. Your PR removes that fix:

// Your code (wrong — counts rejected/abandoned PRs as merged):
const merged = data.items.filter((pr) => pr.state === "closed").length;

// Correct (already in main from PR #197):
const merged = data.items.filter(
  (pr) => pr.pull_request?.merged_at != null
).length;

Restore the pull_request?.merged_at != null check. Also restore the avgReviewMs calculation using only merged PRs (not all closed PRs).

2. Removes combined-account support (regression)

Your PR deletes the accountId === "combined" block and the mergeMetrics import. Users with multiple GitHub accounts lose combined-view. Restore the combined-account merge logic, adding avgCycleTime and weeklyTrend merging alongside the existing fields.

3. GraphQL uses involves:@me — too broad

involves:@me matches PRs where you commented, reacted, etc. Use reviewed-by:@me to get only PRs you actually reviewed:

search(query: "type:pr reviewed-by:@me created:>2026-02-18", type: ISSUE, first: 100)

Then you don't need the pr.author?.login !== viewer filter.

4. Recharts version bump is out of scope

recharts: ^2.12.7 → ^2.15.4 — revert this. Dependency bumps in feature PRs add unnecessary risk.

Fix these four, and the cycle time feature is solid.

@YuktiNandwana
Copy link
Copy Markdown
Author

Hi @Priyanshu-byte-coder! Thanks for the constructive feedback. I have resolved all the noted issues and pushed the fixes:

Restored the correct pull_request?.merged_at != null check from PR #197 and optimized avgReviewMs to only track explicitly merged PRs.

Re-implemented full multi-account aggregation support inside the accountId === "combined" evaluation block for all the new variables (avgCycleTime, weeklyTrend, slowestRepos).

Updated the GraphQL search query to use reviewed-by:@me, making it cleaner and removing the need for post-fetch filters.

Reverted the recharts version bump back to ^2.12.7 inside package.json.

Everything is fully resolved and ready for your final review and merge!

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. Cache removal regression — removes withMetricsCache entirely. Every load now makes two HTTP requests (REST + GraphQL) to GitHub with no caching. Restore the cache wrapper.

2. Wrong mergeRate denominator — uses data.total_count (all-time GitHub total) which gives near-zero rates for active users. The prior code correctly used sampleTotal (items actually fetched). Revert this change.

3. Pervasive any types — GraphQL result typed as any throughout. Add proper interfaces.

4. Broken combined-account pathPromise.all instead of Promise.allSettled means one failed account token fetch crashes the entire response. Use Promise.allSettled.

5. Missing EOF newlines on both changed files.

6. Leading whitespace on import lines — spurious diff noise, remove.

@Priyanshu-byte-coder Priyanshu-byte-coder added level:intermediate GSSoC: Intermediate difficulty (35 pts) gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature labels May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution level:intermediate GSSoC: Intermediate difficulty (35 pts) type:feature GSSoC type bonus: new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Add code review cycle time metric — time from PR open to first review

2 participants