mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-08-14 14:26:23 +00:00
feature: fetch only requested data from GitHub GraphQL API to reduce load (#3208)
* feature: fetch only requested data from GitHub GraphQL API to reduce load * dev * dev
This commit is contained in:
+82
-24
@@ -122,12 +122,12 @@ describe("Test fetchStats", () => {
|
||||
totalCommits: 100,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 240,
|
||||
mergedPRsPercentage: 80,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalReviews: 50,
|
||||
totalStars: 300,
|
||||
totalDiscussionsStarted: 10,
|
||||
totalDiscussionsAnswered: 40,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
@@ -158,12 +158,12 @@ describe("Test fetchStats", () => {
|
||||
totalCommits: 100,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 240,
|
||||
mergedPRsPercentage: 80,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalReviews: 50,
|
||||
totalStars: 300,
|
||||
totalDiscussionsStarted: 10,
|
||||
totalDiscussionsAnswered: 40,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
@@ -200,12 +200,12 @@ describe("Test fetchStats", () => {
|
||||
totalCommits: 1000,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 240,
|
||||
mergedPRsPercentage: 80,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalReviews: 50,
|
||||
totalStars: 300,
|
||||
totalDiscussionsStarted: 10,
|
||||
totalDiscussionsAnswered: 40,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
@@ -249,12 +249,12 @@ describe("Test fetchStats", () => {
|
||||
totalCommits: 1000,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 240,
|
||||
mergedPRsPercentage: 80,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalReviews: 50,
|
||||
totalStars: 200,
|
||||
totalDiscussionsStarted: 10,
|
||||
totalDiscussionsAnswered: 40,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
@@ -280,12 +280,12 @@ describe("Test fetchStats", () => {
|
||||
totalCommits: 100,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 240,
|
||||
mergedPRsPercentage: 80,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalReviews: 50,
|
||||
totalStars: 400,
|
||||
totalDiscussionsStarted: 10,
|
||||
totalDiscussionsAnswered: 40,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
@@ -311,12 +311,12 @@ describe("Test fetchStats", () => {
|
||||
totalCommits: 100,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 240,
|
||||
mergedPRsPercentage: 80,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalReviews: 50,
|
||||
totalStars: 300,
|
||||
totalDiscussionsStarted: 10,
|
||||
totalDiscussionsAnswered: 40,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
@@ -336,6 +336,64 @@ describe("Test fetchStats", () => {
|
||||
followers: 100,
|
||||
});
|
||||
|
||||
expect(stats).toStrictEqual({
|
||||
contributedTo: 61,
|
||||
name: "Anurag Hazra",
|
||||
totalCommits: 100,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalReviews: 50,
|
||||
totalStars: 300,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
|
||||
it("should not fetch additional stats data when it not requested", async () => {
|
||||
let stats = await fetchStats("anuraghazra");
|
||||
const rank = calculateRank({
|
||||
all_commits: false,
|
||||
commits: 100,
|
||||
prs: 300,
|
||||
reviews: 50,
|
||||
issues: 200,
|
||||
repos: 5,
|
||||
stars: 300,
|
||||
followers: 100,
|
||||
});
|
||||
|
||||
expect(stats).toStrictEqual({
|
||||
contributedTo: 61,
|
||||
name: "Anurag Hazra",
|
||||
totalCommits: 100,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalReviews: 50,
|
||||
totalStars: 300,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
|
||||
it("should fetch additional stats when it requested", async () => {
|
||||
let stats = await fetchStats("anuraghazra", false, [], true, true, true);
|
||||
const rank = calculateRank({
|
||||
all_commits: false,
|
||||
commits: 100,
|
||||
prs: 300,
|
||||
reviews: 50,
|
||||
issues: 200,
|
||||
repos: 5,
|
||||
stars: 300,
|
||||
followers: 100,
|
||||
});
|
||||
|
||||
expect(stats).toStrictEqual({
|
||||
contributedTo: 61,
|
||||
name: "Anurag Hazra",
|
||||
|
||||
Reference in New Issue
Block a user