Skip to content

Added [feature] : Contribution Score#503

Merged
mehul-m-prajapati merged 2 commits into
GitMetricsLab:mainfrom
Harshit-collab104:feat/contribution-score
May 29, 2026
Merged

Added [feature] : Contribution Score#503
mehul-m-prajapati merged 2 commits into
GitMetricsLab:mainfrom
Harshit-collab104:feat/contribution-score

Conversation

@Harshit-collab104
Copy link
Copy Markdown
Contributor

@Harshit-collab104 Harshit-collab104 commented May 25, 2026

Related Issue


Description

  • Added a contribution score based on:
    • Merged PRs: +5
    • Open PRs: +2
    • Closed PRs: +1
    • Created issues: +1
  • Displayed the total contribution score in the tracker UI.

How Has This Been Tested?

  • Locally Tested

Type of Change

  • Bug fix
  • New feature
  • Code style update
  • Breaking change
  • Documentation update

Summary by CodeRabbit

Release Notes

  • New Features

    • Tracker page now displays a new Contribution Score section that computes and visualizes GitHub contributions based on merged PRs, open PRs, closed/non-merged PRs, and issues created, displayed in a responsive grid.
  • Improvements

    • Enhanced data-fetching flow with improved request stability and more robust error handling when retrieving GitHub data.

Review Change Stack

@netlify
Copy link
Copy Markdown

netlify Bot commented May 25, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit 24e6905
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a19c3b9472f860008babe11
😎 Deploy Preview https://deploy-preview-503--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

Warning

Review limit reached

@mehul-m-prajapati, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 42 minutes and 3 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4bf27fc9-02b4-45cf-b334-7eb3e88f2954

📥 Commits

Reviewing files that changed from the base of the PR and between 132e9ad and 24e6905.

📒 Files selected for processing (2)
  • src/hooks/useGitHubData.ts
  • src/pages/Tracker/Tracker.tsx
📝 Walkthrough

Walkthrough

This PR implements a contribution scoring system that quantifies user participation. It refactors Octokit initialization from useMemo to useRef for stability, extends useGitHubData with parallel GitHub search queries to compute weighted contribution scores, and updates the Tracker page to fetch data on form submission and display scores in a new UI section.

Changes

Contribution Score Feature Implementation

Layer / File(s) Summary
Octokit Ref-Based Initialization
src/hooks/useGitHubAuth.ts
octokitRef is initialized immediately with a default Octokit() instance and updated via useEffect when token changes. getOctokit is now a stable useCallback that returns the current ref value, eliminating the prior username dependency that could return null.
Contribution Score Type System and Computation
src/hooks/useGitHubData.ts
Introduces ContributionScore type with counts for merged PRs, open PRs, closed/non-merged PRs, and created issues. Adds parallel fetchCount calls across multiple GitHub search queries, applies score weights (merged +5, open +2, closed +1, issues +1), and integrates scoring into fetchData with staleness guarding and error handling that resets the score on failure.
Tracker Data Fetch Control and Form Submission
src/pages/Tracker/Tracker.tsx
Introduces submittedUsername state to gate data fetching. Replaces auto-fetch effect with one triggered only on submittedUsername changes. handleSubmit now trims input, prevents redundant submissions, resets pagination when needed, and triggers immediate fetch when on first page.
Contribution Score UI Rendering
src/pages/Tracker/Tracker.tsx
Derives scoreItems from contributionScore fields (merged/open/closed PRs and issues) with computed points and descriptive labels. Renders a new Material UI Paper block displaying total score and a responsive grid of score tiles.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • GitMetricsLab/github_tracker#238: Modifies useGitHubAuth.ts's Octokit initialization and selection logic, directly related to this PR's refactor of Octokit storage from useMemo to useRef.
  • GitMetricsLab/github_tracker#298: Updates useGitHubData.ts's error handling and catch branches, overlapping with this PR's new try/catch scoring logic and error state management.
  • GitMetricsLab/github_tracker#255: Refactors useGitHubData.ts and Tracker.tsx for analytics/dashboard support, directly related to this PR's contribution score queries and Tracker UI changes.

Suggested labels

gssoc25, level:advanced, type:feature, quality:clean

Suggested reviewers

  • mehul-m-prajapati

Poem

A score is born from queries deep and wide,
Merged PRs and issues bundled with pride,
With weights so fair and points that gleam,
The Tracker now shows a user's dream! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Added [feature] : Contribution Score' is directly related to the main change, which implements a contribution score feature in the tracker.
Description check ✅ Passed The description follows the template structure and covers all required sections: Related Issue, Description with scoring logic, How Has This Been Tested, and Type of Change selection.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #340: contribution score calculation with correct weights (Merged +5, Open +2, Closed +1, Issues +1) and UI display.
Out of Scope Changes check ✅ Passed The PR includes necessary refactoring of useGitHubAuth hook (improved Octokit management) and modifications to useGitHubData/Tracker to support the contribution score feature, all directly supporting the core objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/pages/Tracker/Tracker.tsx (1)

54-72: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Remove the broken authError destructure or restore it in the hook.

useGitHubAuth() in src/hooks/useGitHubAuth.ts no longer returns an error field, but this component still destructures error: authError. That breaks the hook contract and should fail type-checking before this page renders.

Suggested fix
   const {
     username,
     setUsername,
     token,
     setToken,
-    error: authError,
     getOctokit,
   } = useGitHubAuth();
@@
-      {(authError || dataError) && (
+      {dataError && (
         <Alert severity="error" sx={{ mb: 3 }}>
-          {authError || dataError}
+          {dataError}
         </Alert>
       )}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/Tracker/Tracker.tsx` around lines 54 - 72, Tracker.tsx is
destructuring a non-existent error field as "authError" from useGitHubAuth(),
which breaks the hook contract; either remove "error: authError" from the
destructure list in the Tracker component (alongside username, setUsername,
token, setToken, getOctokit) or restore an error field in the useGitHubAuth
hook's return value so it exposes error (and update its type signature). Locate
useGitHubAuth and the destructure in Tracker.tsx and apply one of these two
fixes so the returned shape matches the component's expectations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/hooks/useGitHubAuth.ts`:
- Around line 9-17: Summary: The Octokit instance can be stale/unauthed because
octokitRef.current is set in a useEffect([token]) and may lag a fetch triggered
immediately; derive it during render instead. Fix: replace the effect-driven
assignment with a render-derived, memoized Octokit based on token (e.g., useMemo
or compute a local octokit variable) and have getOctokit return that memoized
instance; update getOctokit’s dependencies to include token (or return the
memoized value directly) so useGitHubData.fetchData / Tracker.handleSubmit
always see an Octokit created with the current PAT; reference octokitRef,
useGitHubAuth, getOctokit, Octokit, useEffect, useCallback,
useGitHubData.fetchData, and submittedUsername when making the change.

In `@src/hooks/useGitHubData.ts`:
- Around line 302-319: The inner try/catch around fetchContributionScore
currently swallows errors; change the inner catch to catch the error (e.g.,
catch (err)) and either rethrow it so the outer catch in the same async flow
handles status-based mapping (401/403/404/rate-limit) or replicate the outer
error/status handling (inspect err.status/message and set rateLimited, setError
accordingly) before possibly setting emptyContributionScore; ensure you still
check requestId === lastRequestId.current before mutating state
(setContributionScore/setError) and prefer rethrowing to avoid duplicating logic
so rateLimited and other status flags are set by the existing outer catch.

In `@src/pages/Tracker/Tracker.tsx`:
- Around line 85-90: The effect in useEffect is rerunning on tab changes but
calls fetchData without the current tab, causing redundant searches; update the
fetchData call in the useEffect to pass the current tab (tab) into fetchData’s
activeTab parameter and ensure fetchData’s signature (fetchData(...,
activeTab?)) accepts and respects that parameter when composing GitHub queries
(verify the fetchData implementation uses the activeTab argument rather than
defaulting to 'both'); keep the dependency array as [fetchData, page,
submittedUsername, tab].

---

Outside diff comments:
In `@src/pages/Tracker/Tracker.tsx`:
- Around line 54-72: Tracker.tsx is destructuring a non-existent error field as
"authError" from useGitHubAuth(), which breaks the hook contract; either remove
"error: authError" from the destructure list in the Tracker component (alongside
username, setUsername, token, setToken, getOctokit) or restore an error field in
the useGitHubAuth hook's return value so it exposes error (and update its type
signature). Locate useGitHubAuth and the destructure in Tracker.tsx and apply
one of these two fixes so the returned shape matches the component's
expectations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 857c02dd-af26-4310-809d-384c766b947d

📥 Commits

Reviewing files that changed from the base of the PR and between 6c6bc3e and 132e9ad.

📒 Files selected for processing (3)
  • src/hooks/useGitHubAuth.ts
  • src/hooks/useGitHubData.ts
  • src/pages/Tracker/Tracker.tsx

Comment thread src/hooks/useGitHubAuth.ts
Comment thread src/hooks/useGitHubData.ts
Comment thread src/pages/Tracker/Tracker.tsx
@Harshit-collab104 Harshit-collab104 marked this pull request as draft May 28, 2026 15:36
@Harshit-collab104 Harshit-collab104 marked this pull request as ready for review May 28, 2026 15:36
@Harshit-collab104
Copy link
Copy Markdown
Contributor Author

Can this request be merged now

@mehul-m-prajapati mehul-m-prajapati merged commit 81127da into GitMetricsLab:main May 29, 2026
4 of 6 checks passed
@github-actions
Copy link
Copy Markdown

🎉🎉 Thank you for your contribution! Your PR #503 has been merged! 🎉🎉

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 Feature: Contribution Score based on PR's and issues

2 participants