fetch up to 10 pages of repos
This commit is contained in:
+14
-64
@@ -1,58 +1,30 @@
|
||||
# Contributing to [github-readme-stats](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
|
||||
|
||||
- Reporting [an issue](https://github.com/anuraghazra/github-readme-stats/issues/new?assignees=&labels=bug&template=bug_report.yml).
|
||||
- [Discussing](https://github.com/anuraghazra/github-readme-stats/discussions) the current state of the code.
|
||||
- Submitting [a fix](https://github.com/anuraghazra/github-readme-stats/compare).
|
||||
- Proposing [new features](https://github.com/anuraghazra/github-readme-stats/issues/new?assignees=&labels=enhancement&template=feature_request.yml).
|
||||
- Becoming a maintainer.
|
||||
|
||||
## All Changes Happen Through Pull Requests
|
||||
|
||||
Pull requests are the best way to propose changes. We actively welcome your pull requests:
|
||||
|
||||
1. Fork the repo and create your branch from `master`.
|
||||
2. If you've added code that should be tested, add some tests' examples.
|
||||
3. If you've changed APIs, update the documentation.
|
||||
4. Issue that pull request!
|
||||
|
||||
## Under the hood of github-readme-stats
|
||||
|
||||
Interested in diving deeper into understanding how github-readme-stats works?
|
||||
|
||||
[Bohdan](https://github.com/Bogdan-Lyashenko) wrote a fantastic in-depth post about it, check it out:
|
||||
|
||||
**[Under the hood of github-readme-stats project](https://codecrumbs.io/library/github-readme-stats)**
|
||||
# Contributing to [GitHub Stats Extended](https://github.com/martin-mfg/github-readme-stats)
|
||||
|
||||
## Local Development
|
||||
|
||||
To run & test github-readme-stats, you need to follow a few simple steps:-
|
||||
_(make sure you already have a [Vercel](https://vercel.com/) account)_
|
||||
To run and test GitHub-Stats-Extended, you need to follow a few simple steps:
|
||||
|
||||
1. Install [Vercel CLI](https://vercel.com/download).
|
||||
2. Fork the repository and clone the code to your local machine.
|
||||
3. Run `npm install` in the repository root.
|
||||
4. Run the command `vercel` in the root and follow the steps there.
|
||||
5. Run the command `vercel dev` to start a development server at <http://localhost:3000>.
|
||||
6. Create a `.env` file in the root and add the following line `NODE_ENV=development`, this will disable caching for local development.
|
||||
7. The cards will then be available from this local endpoint (i.e. `http://localhost:3000/api?username=anuraghazra`).
|
||||
1. make sure you have a [Vercel](https://vercel.com/) account
|
||||
2. Install [Vercel CLI](https://vercel.com/download).
|
||||
3. Fork the repository and clone the code to your local machine.
|
||||
4. Run `npm install` in the repository root.
|
||||
5. Run the command `vercel` in the root and follow the steps there.
|
||||
6. Run the command `vercel dev` to start a development server at <http://localhost:3000>.
|
||||
7. Create a `.env` file in the root and add the following line `NODE_ENV=development`, this will disable caching for local development.
|
||||
8. The cards will then be available from this local endpoint (i.e. `http://localhost:3000/api?username=anuraghazra`).
|
||||
|
||||
> [!NOTE]
|
||||
> You can debug the package code in [Vscode](https://code.visualstudio.com/) by using the [Node.js: Attach to process](https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_setting-up-an-attach-configuration) debug option. You can also debug any tests using the [VSCode Jest extension](https://marketplace.visualstudio.com/items?itemName=Orta.vscode-jest). For more information, see https://github.com/jest-community/vscode-jest/issues/912.
|
||||
|
||||
## Themes Contribution
|
||||
|
||||
We're currently paused addition of new themes to decrease maintenance efforts. All pull requests related to new themes will be closed.
|
||||
|
||||
> [!NOTE]
|
||||
> If you are considering contributing your theme just because you are using it personally, then instead of adding it to our theme collection, you can use card [customization options](./readme.md#customization).
|
||||
We have stopped the addition of new themes to decrease maintenance efforts. If you are considering contributing your theme just because you are using it personally, then instead of adding it to our theme collection, you can use card [customization options](./readme.md#customization).
|
||||
|
||||
## Translations Contribution
|
||||
|
||||
GitHub Readme Stats supports multiple languages, if we are missing your language, you can contribute it! You can check the currently supported languages [here](./readme.md#available-locales).
|
||||
GitHub-Stats-Extended supports multiple languages. If we are missing your language, you can contribute it! You can check the currently supported languages [here](./readme.md#available-locales).
|
||||
|
||||
To contribute your language you need to edit the [src/translations.js](./src/translations.js) file and add new property to each object where the key is the language code in [ISO 639-1 standard](https://www.andiamo.co.uk/resources/iso-language-codes/) and the value is the translated string.
|
||||
To contribute your language you need to edit the [src/translations.js](./src/translations.js) file and add a new property to each object where the key is the language code in [ISO 639-1 standard](https://www.andiamo.co.uk/resources/iso-language-codes/) and the value is the translated string.
|
||||
|
||||
## Any contributions you make will be under the MIT Software License
|
||||
|
||||
@@ -60,7 +32,7 @@ In short, when you submit changes, your submissions are understood to be under t
|
||||
|
||||
## Report issues/bugs using GitHub's [issues](https://github.com/anuraghazra/github-readme-stats/issues)
|
||||
|
||||
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/anuraghazra/github-readme-stats/issues/new/choose); it's that easy!
|
||||
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/anuraghazra/github-readme-stats/issues/new/choose).
|
||||
|
||||
## Frequently Asked Questions (FAQs)
|
||||
|
||||
@@ -68,13 +40,6 @@ We use GitHub issues to track public bugs. Report a bug by [opening a new issue]
|
||||
|
||||
> **Ans:** &hide=jupyter%20notebook
|
||||
|
||||
**Q:** I could not figure out how to deploy on my own Vercel instance
|
||||
|
||||
> **Ans:**
|
||||
>
|
||||
> - docs: <https://github.com/anuraghazra/github-readme-stats/#deploy-on-your-own-vercel-instance>
|
||||
> - YT tutorial by codeSTACKr: <https://www.youtube.com/watch?v=n6d4KHSKqGk&feature=youtu.be&t=107>
|
||||
|
||||
**Q:** Language Card is incorrect
|
||||
|
||||
> **Ans:** Please read all the related issues/comments before opening any issues regarding language card stats:
|
||||
@@ -87,21 +52,6 @@ We use GitHub issues to track public bugs. Report a bug by [opening a new issue]
|
||||
|
||||
> **Ans:** We can only count public commits & we cannot access any other private info of any users, so it's not possible. The only way to count your personal private stats is to deploy on your own instance & use your own PAT (Personal Access Token)
|
||||
|
||||
### Bug Reports
|
||||
|
||||
**Great Bug Reports** tend to have:
|
||||
|
||||
- A quick summary and/or background
|
||||
- Steps to reproduce
|
||||
- Be specific!
|
||||
- Share the snapshot, if possible.
|
||||
- GitHub Readme Stats' live link
|
||||
- What actually happens
|
||||
- What you expected would happen
|
||||
- Notes (possibly including why you think this might be happening or stuff you tried that didn't work)
|
||||
|
||||
People _love_ thorough bug reports. I'm not even kidding.
|
||||
|
||||
### Feature Request
|
||||
|
||||
**Great Feature Requests** tend to have:
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Anurag Hazra
|
||||
Copyright (c) 2020 Anurag Hazra, martin-mfg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+37
-967
File diff suppressed because it is too large
Load Diff
@@ -114,7 +114,7 @@ const fetcher = (variables, token) => {
|
||||
* @param {string[]} ownerAffiliations The owner affiliations to filter by. Default: OWNER.
|
||||
* @returns {Promise<import('axios').AxiosResponse>} Axios response.
|
||||
*
|
||||
* @description This function supports multi-page fetching if the 'FETCH_MULTI_PAGE_STARS' environment variable is set to true.
|
||||
* @description This function supports multi-page fetching if the 'FETCH_MULTI_PAGE_STARS' environment variable is set to true or a limit of fetches.
|
||||
*/
|
||||
const statsFetcher = async ({
|
||||
username,
|
||||
@@ -127,6 +127,7 @@ const statsFetcher = async ({
|
||||
let stats;
|
||||
let hasNextPage = true;
|
||||
let endCursor = null;
|
||||
let fetchedPages = 0;
|
||||
while (hasNextPage) {
|
||||
const variables = {
|
||||
login: username,
|
||||
@@ -146,17 +147,23 @@ const statsFetcher = async ({
|
||||
// Store stats data.
|
||||
const repoNodes = res.data.data.user.repositories.nodes;
|
||||
if (stats) {
|
||||
if (fetchedPages === 1) {
|
||||
// make deep copy of stats to avoid altering the cached response object in frontend
|
||||
stats = structuredClone(stats);
|
||||
}
|
||||
stats.data.data.user.repositories.nodes.push(...repoNodes);
|
||||
} else {
|
||||
stats = res;
|
||||
}
|
||||
|
||||
// Disable multi page fetching on public Vercel instance due to rate limits.
|
||||
fetchedPages++;
|
||||
const repoNodesWithStars = repoNodes.filter(
|
||||
(node) => node.stargazers.totalCount !== 0,
|
||||
);
|
||||
hasNextPage =
|
||||
process.env.FETCH_MULTI_PAGE_STARS === "true" &&
|
||||
(process.env.FETCH_MULTI_PAGE_STARS === "true" ||
|
||||
process.env.FETCH_MULTI_PAGE_STARS > fetchedPages) &&
|
||||
repoNodes.length === repoNodesWithStars.length &&
|
||||
res.data.data.user.repositories.pageInfo.hasNextPage;
|
||||
endCursor = res.data.data.user.repositories.pageInfo.endCursor;
|
||||
|
||||
@@ -31,7 +31,7 @@ export const DEMO_WAKATIME_USER = 'ffflabs';
|
||||
|
||||
window.process = {
|
||||
env: {
|
||||
FETCH_MULTI_PAGE_STARS: 'true',
|
||||
FETCH_MULTI_PAGE_STARS: 10,
|
||||
PAT_1: 'placeholderPAT', // so the backend's retryer.js sees there is 1 PAT and sets `RETRIES` accordingly
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user