fix: return null deltaPercentage when previous month has zero contributions#913
Merged
JhaSourav07 merged 1 commit intoMay 28, 2026
Conversation
…utions - Hardcoded +100% was misleading regardless of current month total - deltaPercentage is now number | null in MonthlyStats type - calculateMonthlyStats returns null when previousMonthTotal === 0 - generateMonthlySVG and generateAutoThemeMonthlySVG render 'N/A' for null - Updated test to expect null instead of 100
|
👋 Hey @KaparthyReddy, welcome to CommitPulse! 🎉 Thanks for opening your first pull request — this is a big deal and we appreciate the effort! While you wait for a review, please double-check:
A maintainer will review your PR shortly. Hang tight! 🚀 |
Aamod007
approved these changes
May 28, 2026
|
🎉 Congratulations @KaparthyReddy! Your PR has been successfully merged. 🚀 Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.
Keep building! 💻✨ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #908
Description
calculateMonthlyStatsinlib/calculate.tshardcodeddeltaPercentage = 100wheneverpreviousMonthTotal === 0, regardless of how many contributions were made this month. This is mathematically undefined — dividing by zero has no meaningful percentage result. A user with 1 commit vs 0 last month and a user with 500 commits vs 0 last month both saw+100%, which is misleading and factually incorrect.Changes:
deltaPercentageis now typed asnumber | nullinMonthlyStats(types/index.ts)calculateMonthlyStatsreturnsnullwhenpreviousMonthTotal === 0instead of hardcoded100generateMonthlySVGandgenerateAutoThemeMonthlySVGnow renderN/AwhendeltaPercentageisnulllib/calculate.test.tsto expectnullinstead of100Files changed:
lib/calculate.ts,lib/svg/generator.ts,types/index.ts,lib/calculate.test.tsPillar
Visual Preview
N/A — delta indicator will now show
N/Ainstead of+100%for users with zero contributions last month.Checklist before requesting a review:
CONTRIBUTING.mdfile.npm run formatandnpm run lintlocally and resolved all errors.README.mdif I added a new theme or URL parameter.