Skip to content

Commit 5a7929c

Browse files
authored
docs(github): add JSDoc comments for achievement utilities (JhaSourav07#929)
## Description Added JSDoc documentation for `generateAchievements` and the milestone constants in `lib/github.ts.` ### Changes made - Added documentation for `generateAchievements` - Added documentation for `CONTRIBUTION_MILESTONES` - Added documentation for `STREAK_MILESTONES` - Added `@param`, `@returns`, and `@example tags` - Documented progress calculation and clamping behavior - No functional changes Fixes JhaSourav07#350 ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview <img width="1171" height="562" alt="image" src="https://github.com/user-attachments/assets/03d9f25d-b982-4578-b62d-0d02d88606cc" /> <img width="1257" height="725" alt="image" src="https://github.com/user-attachments/assets/f0740825-c944-4231-be3c-b7ef4784c567" /> ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [x] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have started the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [x] 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.
2 parents fe9fd43 + c261ec2 commit 5a7929c

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

lib/github.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,30 @@ export async function getWrappedData(username: string, year: string) {
496496
* UTILS & EXPORTS
497497
* ========================================================================== */
498498

499+
/**
500+
* Generates contribution and streak achievement metadata for a user.
501+
*
502+
* Achievements are unlocked when the provided contribution count
503+
* or streak value meets the corresponding milestone threshold.
504+
*
505+
* Progress values are clamped between 0 and 100 using `Math.min`
506+
* to prevent percentages from exceeding 100%.
507+
*
508+
* @param totalContributions - Total number of contributions made by the user.
509+
* @param currentStreak - Current active contribution streak in days.
510+
* @param weekendCommits - Total number of contributions made on weekends.
511+
* @param uniqueLanguages - Number of distinct languages used.
512+
*
513+
* @returns An array of achievement objects for contribution and streak milestones,
514+
* including unlock status, progress percentage, threshold values, and display metadata.
515+
*
516+
* @example
517+
* ```ts
518+
* const achievements = generateAchievements(125, 10);
519+
*
520+
* console.log(achievements);
521+
* ```
522+
*/
499523
export function generateAchievements(
500524
totalContributions: number,
501525
currentStreak: number,

0 commit comments

Comments
 (0)