refactor(github): extract computeDeveloperScore function#920
refactor(github): extract computeDeveloperScore function#920deepsikha-dash wants to merge 2 commits into
Conversation
|
@deepsikha-dash is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
🚨 Hey @deepsikha-dash, the CI Pipeline is failing on this PR and it has been marked as Please fix the issues before this can be reviewed. Here's how: 1. Run checks locally before pushing: npm run format:check # Check Prettier formatting
npm run lint # Run ESLint
npm run typecheck # TypeScript type check
npm run test # Run unit tests (Vitest)
npm run build # Verify production build passes2. Auto-fix common issues: npm run format # Auto-fix formatting with Prettier
npm run lint -- --fix # Auto-fix lint errors where possible3. Check the full failure log here: Once you push a fix and the CI passes, the |
cdba6cb to
28ba20f
Compare
Aamod007
left a comment
There was a problem hiding this comment.
@deepsikha-dash removed the cacheKey test suite that function is still actively used in 3 places (github.ts:275,374,437). Please restore those 6 tests. dead code .
There was a problem hiding this comment.
Pull request overview
This PR refactors the GitHub dashboard developer score calculation into a reusable pure helper and updates dashboard aggregation to call it.
Changes:
- Added
computeDeveloperScore()inlib/github.ts. - Replaced inline score arithmetic in
getFullDashboardData. - Added initial tests for zero-input and max-clamp score behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/github.ts |
Extracts the developer score formula and uses it in dashboard data construction. |
lib/github.test.ts |
Adds tests for computeDeveloperScore, but removes unrelated existing helper tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| it('supports repos kind', () => { | ||
| expect(cacheKey('repos', 'testuser')).toContain('repos'); | ||
| describe('computeDeveloperScore', () => { |
| describe('computeDeveloperScore', () => { | ||
| it('returns 0 for all zero inputs', () => { | ||
| expect( | ||
| computeDeveloperScore({ | ||
| repos: 0, | ||
| followers: 0, | ||
| stars: 0, | ||
| contributions: 0, | ||
| longestStreak: 0, | ||
| }) | ||
| ).toBe(0); | ||
| }); | ||
|
|
||
| it('supports contributions kind', () => { | ||
| expect(cacheKey('contributions', 'testuser')).toContain('contributions'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('buildCommitClock', () => { | ||
| it('aggregates commits correctly by day of week', () => { | ||
| const allDays = [ | ||
| { date: '2024-06-09', contributionCount: 2 }, // Sun | ||
| { date: '2024-06-10', contributionCount: 5 }, // Mon | ||
| { date: '2024-06-10', contributionCount: 3 }, // Mon | ||
| { date: '2024-06-12', contributionCount: 4 }, // Wed | ||
| ]; | ||
|
|
||
| const result = buildCommitClock(allDays); | ||
|
|
||
| expect(result).toEqual([ | ||
| { day: 'Sun', commits: 2 }, | ||
| { day: 'Mon', commits: 8 }, | ||
| { day: 'Tue', commits: 0 }, | ||
| { day: 'Wed', commits: 4 }, | ||
| { day: 'Thu', commits: 0 }, | ||
| { day: 'Fri', commits: 0 }, | ||
| { day: 'Sat', commits: 0 }, | ||
| ]); | ||
| it('caps score at 100', () => { | ||
| expect( | ||
| computeDeveloperScore({ | ||
| repos: 1000, | ||
| followers: 1000, | ||
| stars: 1000, | ||
| contributions: 10000, | ||
| longestStreak: 1000, | ||
| }) | ||
| ).toBe(100); | ||
| }); | ||
| }); |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
13 similar comments
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
|
Please pull the latest changes and resolve the conflicts so we can review it! git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-leaseOnce resolved, the |
0a54c92 to
ffa8e8f
Compare
Description
Extracted the developer score calculation into a pure
computeDeveloperScore()function.Changes made
computeDeveloperScore()helpergetFullDashboardDataFixes #297
Pillar
Visual Preview
N/A
Checklist before requesting a review:
CONTRIBUTING.mdfile.localhost:3000/api/streak?user=YOUR_USERNAME).npm run formatandnpm run lintlocally and resolved all errors (CI will fail otherwise).feat(themes): ...,fix(calculate): ...).README.mdif I added a new theme or URL parameter.