feat: Enhance Repository-Specific Contribution Tracking - #8981
feat: Enhance Repository-Specific Contribution Tracking#8981Aditya8369 wants to merge 2 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! |
|
🚨 Hey @Aditya8369, 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 |
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