Skip to content

feat(metrics): add GitHub Discussions metrics route and DiscussionsMe… - #3253

Closed
Nareshkumawat-star wants to merge 3 commits into
Priyanshu-byte-coder:mainfrom
Nareshkumawat-star:feature/discussions-metrics
Closed

feat(metrics): add GitHub Discussions metrics route and DiscussionsMe…#3253
Nareshkumawat-star wants to merge 3 commits into
Priyanshu-byte-coder:mainfrom
Nareshkumawat-star:feature/discussions-metrics

Conversation

@Nareshkumawat-star

Copy link
Copy Markdown
Contributor

Summary

Adds a new GitHub Discussions metrics integration to DevTrack. This includes an enhanced GraphQL-backed API route (/api/metrics/discussions) and a new interactive DiscussionsMetrics component featuring key stat cards, a category breakdown bar chart via Recharts, and a time-range selector (7d / 30d / 90d).


#closes : #3252

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📝 Documentation update
  • ♻️ Refactor / code cleanup (no functional change)
  • ⚡ Performance improvement
  • 🔒 Security fix
  • 🧪 Tests only

What Changed

  • src/app/api/metrics/discussions/route.ts: Updated the API route to fetch user discussion contributions, comments, accepted answers, and discussion nodes via GitHub GraphQL API (/graphql). Calculates answeredRate %, top 3 discussion categories, and accepts time-range parameters (days=7/30/90).
  • src/components/DiscussionsMetrics.tsx: Created a client component with stat cards (Discussions Started, Comments Left, Answered Rate %), a horizontal Recharts Bar Chart (Discussions by Category), interactive time-range selector buttons, multi-account support (useAccount), loading skeletons, error states, and empty states.
  • src/components/DiscussionsWidget.tsx: Updated to render DiscussionsMetrics directly within the customizable dashboard.

How to Test

  1. Navigate to the DevTrack dashboard.
  2. Locate the Discussion Activity widget.
  3. Click through the time range selector buttons (7d, 30d, 90d) to ensure metrics and category distribution re-fetch correctly.
  4. Verify that stat cards (Discussions Started, Comments Left, Answered Rate %) and the category bar chart render accurately.

Expected result: The discussion widget dynamically updates with stat metrics, category bar chart, and time range selection.


Checklist

  • Self-reviewed my own diff
  • No unnecessary console.log, debug code, or commented-out blocks
  • Tested responsive layout and mobile display
  • Preserved backward compatibility for legacy field names (commentsGiven, markedAsAnswer)

Accessibility (UI changes only)

  • Keyboard navigation works correctly
  • Color contrast meets WCAG AA standard
  • ARIA labels / roles added where needed
  • Tested on mobile / responsive layout

Additional Context

  • Direct PR creation link for this branch: https://github.com/Nareshkumawat-star/devtrack/pull/new/feature/discussions-metrics

@github-actions github-actions Bot added type:bug GSSoC type bonus: bug fix type:feature GSSoC type bonus: new feature type:design GSSoC type bonus: UI/design (+10 pts) type:performance GSSoC type bonus: performance (+15 pts) gssoc26 GSSoC 2026 contribution labels Jul 28, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@github-actions github-actions Bot added the type:devops GSSoC type bonus: devops (+15 pts) label Jul 28, 2026
@github-actions github-actions Bot added the type:testing GSSoC type bonus: tests (+10 pts) label Jul 28, 2026
@Nareshkumawat-star

Copy link
Copy Markdown
Contributor Author

Hi @Priyanshu-byte-coder kindly review and merge it

@github-actions

Copy link
Copy Markdown

This PR has been inactive for 21 days. If it is still in progress, please leave an update — otherwise it will be closed in 7 days.

@github-actions github-actions Bot added the stale Inactive for 21+ days label Aug 19, 2026
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Closing due to inactivity. Feel free to reopen or open a new PR if you would like to continue.

@github-actions github-actions Bot closed this Aug 28, 2026
@Priyanshu-byte-coder

Copy link
Copy Markdown
Owner

This is the best PR of your batch — I built it, ran it, and looked at the rendered widget, and it's good work.

What I verified against current main: merges clean, tsc --noEmit clean, full suite 163 files / 2390 tests passing, production build succeeds. Rendered the dashboard and the widget shows correctly: "Discussion Activity" heading with a 7d/30d/90d range toggle, three stat tiles (Discussions Started, Comments Left, Answered Rate with the "7 answered" sub-label), and a Top Categories bar chart. No console errors.

Details I liked: every colour goes through a CSS variable — stroke="var(--border)", fill="var(--accent)" — so it themes correctly instead of hardcoding a blue that breaks in one mode. That's the thing most chart PRs get wrong. Reducing DiscussionsWidget to a thin wrapper around DiscussionsMetrics is the right structure too, and it's squarely in scope: Discussions activity is GitHub activity.

Two things to remove, then I'll merge.

1. src/lib/__tests__/streak.test.ts is a duplicate. It's the same 7 test cases — byte-for-byte the same it(...) names — as the file from your #3254, which I merged as test/streak-calculator.test.ts. Since #3501 widened the vitest include to cover src/**, both copies now run, so the suite executes those 7 assertions twice. Delete the file from this branch.

2. The .github/workflows/pr-star-required.yml change.

-github-token: ${{ secrets.GITHUB_TOKEN }}
+github-token: ${{ secrets.STAR_TOKEN || secrets.GITHUB_TOKEN }}

STAR_TOKEN isn't a secret in this repo, so today it falls through to GITHUB_TOKEN and changes nothing. But it's an unexplained edit to the workflow that gates your own PR, sitting inside a feature branch about Discussions metrics. Even as a no-op that's the kind of change that has to travel on its own PR with a reason attached. If you hit a real problem — GITHUB_TOKEN not being able to read star status from a fork, say — open a separate PR describing it and I'll look properly.

One small thing for later, not blocking: DiscussionsMetricsData declares both commentsLeft and commentsGiven?, and both acceptedAnswers and markedAsAnswer?. Two names for the same number invites drift. Worth settling on one pair and matching the route to it.

Drop those two files and ping me.

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

Labels

gssoc26 GSSoC 2026 contribution stale Inactive for 21+ days type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:devops GSSoC type bonus: devops (+15 pts) type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Add GitHub Discussions metrics widget — total discussions, answered rate, top categories

2 participants