-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(providers): add indivudal GitHub contributions #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(providers): add indivudal GitHub contributions #18
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #18 +/- ##
============================
============================
|
ReenigneArcher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also add an option to set an upper limit to contributions or view them logarithmic, so that one org doesn't end up overtaking everything. radiusMax does not seem to handle this correctly.
| - [**CrowdIn**](https://crowdin.com) | ||
| - [**GitHub**](https://github.com) | ||
| - [**GitHub Contributors**](https://github.com) (contributors to a specific repository) | ||
| - [**GitHub Contributions**](https://github.com) (commit-only contributions aggregated by repository owner across all repos for a single user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - [**GitHub Contributions**](https://github.com) (commit-only contributions aggregated by repository owner across all repos for a single user) | |
| - [**GitHub Contributions**](https://github.com) (merged PRs aggregated by repository owner across all repos for a single user) |
| ; Optional tuning: | ||
| ; Retry attempts for transient errors (5xx), default 3 | ||
| CONTRIBKIT_GITHUB_CONTRIBUTIONS_RETRIES=3 | ||
| ; Initial retry delay in ms, default 500 (exponential backoff with jitter) | ||
| CONTRIBKIT_GITHUB_CONTRIBUTIONS_RETRY_DELAY_MS=500 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ; Optional tuning: | |
| ; Retry attempts for transient errors (5xx), default 3 | |
| CONTRIBKIT_GITHUB_CONTRIBUTIONS_RETRIES=3 | |
| ; Initial retry delay in ms, default 500 (exponential backoff with jitter) | |
| CONTRIBKIT_GITHUB_CONTRIBUTIONS_RETRY_DELAY_MS=500 |
Not necessary.
| 1. **contributionsCollection** - Yearly commit timeline (full history) for discovering repositories you have committed to | ||
| 2. **Search API** - Repositories where you have merged PRs (`is:pr is:merged author:login`) | ||
| - When an owner has only one repo, the link points to that repo; otherwise to the owner profile | ||
| - Better metric than commits as it represents completed, reviewed contributions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - Better metric than commits as it represents completed, reviewed contributions |
| retries: Number(process.env.CONTRIBKIT_GITHUB_CONTRIBUTIONS_RETRIES) || 3, | ||
| retryDelayMs: Number(process.env.CONTRIBKIT_GITHUB_CONTRIBUTIONS_RETRY_DELAY_MS) || 500, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| retries: Number(process.env.CONTRIBKIT_GITHUB_CONTRIBUTIONS_RETRIES) || 3, | |
| retryDelayMs: Number(process.env.CONTRIBKIT_GITHUB_CONTRIBUTIONS_RETRY_DELAY_MS) || 500, |
| // Ensure unique clipPath id per element. Previously, we only hashed the image bytes, | ||
| // which caused duplicates when many items shared the same avatar. Include geometry too. | ||
| const cropId = `c${crypto.createHash('md5').update(`${x}:${y}:${size}:${radius}:${base64Image}`).digest('hex').slice(0, 6)}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Ensure unique clipPath id per element. Previously, we only hashed the image bytes, | |
| // which caused duplicates when many items shared the same avatar. Include geometry too. | |
| const cropId = `c${crypto.createHash('md5').update(`${x}:${y}:${size}:${radius}:${base64Image}`).digest('hex').slice(0, 6)}` | |
| // Unique clipPath id per element, ensuring duplicated images are properly rendered. | |
| const cropId = `c${crypto.createHash('md5').update(`${x}:${y}:${size}:${radius}:${base64Image}`).digest('hex').slice(0, 6)}` |
| { | ||
| retries: config.githubContributions?.retries ?? 3, | ||
| retryDelayMs: config.githubContributions?.retryDelayMs ?? 500, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| { | |
| retries: config.githubContributions?.retries ?? 3, | |
| retryDelayMs: config.githubContributions?.retryDelayMs ?? 500, | |
| }, |
| interface FetchOptions { | ||
| retries?: number | ||
| retryDelayMs?: number | ||
| } | ||
|
|
||
| export async function fetchGitHubContributions( | ||
| token: string, | ||
| login: string, | ||
| options: FetchOptions = {}, | ||
| ): Promise<Sponsorship[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| interface FetchOptions { | |
| retries?: number | |
| retryDelayMs?: number | |
| } | |
| export async function fetchGitHubContributions( | |
| token: string, | |
| login: string, | |
| options: FetchOptions = {}, | |
| ): Promise<Sponsorship[]> { | |
| export async function fetchGitHubContributions( | |
| token: string, | |
| login: string, | |
| ): Promise<Sponsorship[]> { |
| const retries = Math.max(0, options.retries ?? 3) | ||
| const retryDelayMs = Math.max(0, options.retryDelayMs ?? 500) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const retries = Math.max(0, options.retries ?? 3) | |
| const retryDelayMs = Math.max(0, options.retryDelayMs ?? 500) |
| const circles = p(root as any).descendants().slice(1) | ||
|
|
||
| // Draw smaller circles last so they appear on top and are not hidden by larger ones | ||
| circles.sort((a, b) => a.r - b.r) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test without this change.
| /** | ||
| * Number of retries for GitHub GraphQL requests on transient failures (e.g., 5xx). | ||
| * @default 3 | ||
| */ | ||
| retries?: number | ||
| /** | ||
| * Initial retry delay in milliseconds for backoff. | ||
| * @default 500 | ||
| */ | ||
| retryDelayMs?: number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /** | |
| * Number of retries for GitHub GraphQL requests on transient failures (e.g., 5xx). | |
| * @default 3 | |
| */ | |
| retries?: number | |
| /** | |
| * Initial retry delay in milliseconds for backoff. | |
| * @default 500 | |
| */ | |
| retryDelayMs?: number |




Description
Add an individual contributions provider for GitHub.
Screenshot
Issues Fixed or Closed
Roadmap Issues
Type of Change
Checklist
AI Usage