feat: Enhance Repository-Specific Contribution Tracking - #8981
feat: Enhance Repository-Specific Contribution Tracking#8981Aditya8369 wants to merge 4 commits into
Conversation
|
@Aditya8369 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
This pull request significantly enhances the contribution tracking capabilities by scoping contributions to specific repositories and improving validation mechanisms. It aligns well with previous decisions, such as implementing GitHub GraphQL rate limit handling and adding TypeScript validation for the streak route. These improvements will help maintain system stability and user experience. Thank you for your contributions! |
|
If you are still working on this, please push your latest changes or leave a comment to keep it active. |
Aamod007
left a comment
There was a problem hiding this comment.
This is a fantastic feature enhancement! Allowing users to scope their contribution monolith to a specific repository via the &repo=\ parameter adds a lot of value.
Refining the \streakParamsSchema\ in \�alidations.ts\ to enforce the \owner/repo\ format prevents malformed requests early. I also really appreciate how thoroughly you handled the \etchGitHubContributions\ logic to correctly recalculate \ otalContributions\ and zero out non-matching days in the \contributionCalendar\ when a repo is specified. The
epo-contribution.test.ts\ suite covers all the edge cases perfectly.
Labels applied:
- type:feature: Adds repository-scoped contribution tracking.
- level:intermediate: Handles complex GraphQL response transformation and schema validation.
- quality:exceptional: Clean, robustly tested implementation with good cache key logic.
📦 Next.js Bundle Size Report (Gzipped Sizes)
📊 Summary of Totals
|
Summary of Changes
URL Parameter & Schema Validation:
Added repo?: string parameter to baseStreakParamsSchema in
lib/validations.ts
with strict owner/repository-name format validation.
Added repo?: string to BadgeParams and RepoContribution in
types/index.ts
.
GraphQL Scoping & GitHub Fetcher:
Updated FetchOptions and cacheKey in
lib/github.ts
to isolate cache keys per repository (:repo:owner/repo).
Extended the commitContributionsByRepository GraphQL query in fetchContributionsUncached to query contributions(first: 100) { totalCount nodes { occurredAt commitCount } }.
Implemented calendar filtering so that when options.repo is provided, contribution counts per day, total contributions, and repository lists are scoped strictly to the specified repository.
API Route & Title Generation:
Updated
app/api/streak/route.ts
to parse repo and pass it down to fetchGitHubContributions.
Dynamically updated default SVG title to "CommitPulse for owner/repo" when &repo= is provided (unless overridden by custom_title).
Testing:
Added unit tests in
tests/repo-contribution.test.ts
covering parameter validation, cache key generation, and contribution scoping.
Verified that all 6 tests in tests/repo-contribution.test.ts and all 103 tests in lib/github.test.ts pass cleanly.
closes #8977