Skip to content

refactor(github): extract computeDeveloperScore function#920

Open
deepsikha-dash wants to merge 2 commits into
JhaSourav07:mainfrom
deepsikha-dash:refactor-compute-developer-score
Open

refactor(github): extract computeDeveloperScore function#920
deepsikha-dash wants to merge 2 commits into
JhaSourav07:mainfrom
deepsikha-dash:refactor-compute-developer-score

Conversation

@deepsikha-dash
Copy link
Copy Markdown
Contributor

Description

Extracted the developer score calculation into a pure computeDeveloperScore() function.

Changes made

  • Added reusable computeDeveloperScore() helper
  • Replaced inline developer score calculation in getFullDashboardData
  • Added unit tests for:
    • all-zero inputs
    • max score clamping at 100
    • factor saturation cases

Fixes #297

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Visual Preview

N/A

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...).
  • I have updated README.md if I added a new theme or URL parameter.
  • I have started the repo.
  • I have made sure that i have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts).
  • (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 28, 2026

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

@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label May 28, 2026
@github-actions
Copy link
Copy Markdown

🚨 Hey @deepsikha-dash, the CI Pipeline is failing on this PR and it has been marked as status:blocked.

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 passes

2. Auto-fix common issues:

npm run format         # Auto-fix formatting with Prettier
npm run lint -- --fix  # Auto-fix lint errors where possible

3. Check the full failure log here:
👉 View CI Run

Once you push a fix and the CI passes, the status:blocked label will be removed automatically. 💪

@deepsikha-dash deepsikha-dash force-pushed the refactor-compute-developer-score branch from cdba6cb to 28ba20f Compare May 28, 2026 10:41
@github-actions github-actions Bot removed the status:blocked This PR is blocked due to a failing CI check. label May 28, 2026
Copy link
Copy Markdown
Collaborator

@Aamod007 Aamod007 left a comment

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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() in lib/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.

Comment thread lib/github.test.ts

it('supports repos kind', () => {
expect(cacheKey('repos', 'testuser')).toContain('repos');
describe('computeDeveloperScore', () => {
Comment thread lib/github.test.ts
Comment on lines +830 to 854
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);
});
});
@github-actions github-actions Bot added type:refactor Code changes that neither fix a bug nor add a feature needs-rebase This PR has merge conflicts and needs a rebase. labels May 28, 2026
@github-actions
Copy link
Copy Markdown

⚠️ Hey @deepsikha-dash, this PR has merge conflicts with the main branch.

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-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

13 similar comments
@github-actions
Copy link
Copy Markdown

⚠️ Hey @deepsikha-dash, this PR has merge conflicts with the main branch.

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-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @deepsikha-dash, this PR has merge conflicts with the main branch.

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-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @deepsikha-dash, this PR has merge conflicts with the main branch.

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-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @deepsikha-dash, this PR has merge conflicts with the main branch.

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-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @deepsikha-dash, this PR has merge conflicts with the main branch.

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-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @deepsikha-dash, this PR has merge conflicts with the main branch.

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-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @deepsikha-dash, this PR has merge conflicts with the main branch.

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-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @deepsikha-dash, this PR has merge conflicts with the main branch.

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-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @deepsikha-dash, this PR has merge conflicts with the main branch.

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-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @deepsikha-dash, this PR has merge conflicts with the main branch.

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-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @deepsikha-dash, this PR has merge conflicts with the main branch.

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-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @deepsikha-dash, this PR has merge conflicts with the main branch.

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-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions
Copy link
Copy Markdown

⚠️ Hey @deepsikha-dash, this PR has merge conflicts with the main branch.

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-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@deepsikha-dash deepsikha-dash force-pushed the refactor-compute-developer-score branch from 0a54c92 to ffa8e8f Compare May 29, 2026 16:53
@github-actions github-actions Bot added status:blocked This PR is blocked due to a failing CI check. and removed needs-rebase This PR has merge conflicts and needs a rebase. labels May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:blocked This PR is blocked due to a failing CI check. type:refactor Code changes that neither fix a bug nor add a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(github): extract developer score formula into a pure computeDeveloperScore() function

3 participants