Added [feature] : Contribution Score#503
Conversation
✅ Deploy Preview for github-spy ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Warning Review limit reached
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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis 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. ChangesContribution Score Feature Implementation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🎉 Thank you @Harshit-collab104 for your contribution. Please make sure your PR follows https://github.com/GitMetricsLab/github_tracker/blob/main/CONTRIBUTING.md#-pull-request-guidelines
There was a problem hiding this comment.
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 winRemove the broken
authErrordestructure or restore it in the hook.
useGitHubAuth()insrc/hooks/useGitHubAuth.tsno longer returns anerrorfield, but this component still destructureserror: 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
📒 Files selected for processing (3)
src/hooks/useGitHubAuth.tssrc/hooks/useGitHubData.tssrc/pages/Tracker/Tracker.tsx
|
Can this request be merged now |
|
🎉🎉 Thank you for your contribution! Your PR #503 has been merged! 🎉🎉 |
Related Issue
Description
How Has This Been Tested?
Type of Change
Summary by CodeRabbit
Release Notes
New Features
Improvements