adjusted collection method

This commit is contained in:
luke-hagar-sp
2024-02-29 17:38:35 -05:00
parent d2e47ce10e
commit cd6002a9f4
2 changed files with 78 additions and 36 deletions

View File

@@ -2,10 +2,10 @@
"name": "Luke Hagar", "name": "Luke Hagar",
"username": "lukehagar", "username": "lukehagar",
"repoViews": 1589, "repoViews": 1589,
"linesOfCodeChanged": 7397302, "linesOfCodeChanged": 10613251,
"totalCommits": 1582, "totalCommits": 1582,
"totalPullRequests": 48, "totalPullRequests": 48,
"codeByteTotal": 11731473, "codeByteTotal": 11731760,
"topLanguages": [ "topLanguages": [
{ {
"languageName": "Svelte", "languageName": "Svelte",
@@ -20,7 +20,7 @@
{ {
"languageName": "TypeScript", "languageName": "TypeScript",
"color": "#3178c6", "color": "#3178c6",
"value": 3157579 "value": 3157866
}, },
{ {
"languageName": "Makefile", "languageName": "Makefile",
@@ -82,5 +82,5 @@
"starCount": 113, "starCount": 113,
"closedIssues": 12, "closedIssues": 12,
"openIssues": 10, "openIssues": 10,
"fetchedAt": 1709244633038 "fetchedAt": 1709246251263
} }

View File

@@ -43,41 +43,71 @@ export async function getUserData(
); );
} }
export async function getRepoData(octokit: Octokit, username: string) { export async function getRepoData(
octokit: Octokit,
username: string
): Promise<GraphQlQueryResponseData> {
return octokit.graphql.paginate( return octokit.graphql.paginate(
`query repoInfo ($login: String!, $cursor: String) { `query repoInfo($login: String!, $cursor: String) {
user(login: $login) { user(login: $login) {
repositories( repositories(
orderBy: {field: STARGAZERS, direction: DESC} orderBy: {field: STARGAZERS, direction: DESC}
ownerAffiliations: OWNER ownerAffiliations: OWNER
isFork: false isFork: false
first: 100 first: 100
after: $cursor ) {
) { totalCount
totalCount nodes {
nodes { stargazers {
stargazers { totalCount
totalCount }
forkCount
name
languages(first: 10, orderBy: {field: SIZE, direction: DESC}) {
edges {
size
node {
color
name
}
}
}
} }
forkCount pageInfo {
name endCursor
languages(first: 10, orderBy: {field: SIZE, direction: DESC}) { hasNextPage
edges { }
size }
node { repositoriesContributedTo(
color first: 100
name includeUserRepositories: false
orderBy: {field: STARGAZERS, direction: DESC}
contributionTypes: [COMMIT, PULL_REQUEST, REPOSITORY, PULL_REQUEST_REVIEW]
after: $cursor
) {
pageInfo {
hasNextPage
endCursor
}
nodes {
nameWithOwner
stargazers {
totalCount
}
forkCount
languages(first: 10, orderBy: {field: SIZE, direction: DESC}) {
edges {
size
node {
name
color
}
} }
} }
} }
} }
pageInfo {
endCursor
hasNextPage
}
} }
} }`,
}`,
{ {
login: username, login: username,
} }
@@ -319,6 +349,8 @@ try {
// getContributionCollection(octokit, accountCreationDate), // getContributionCollection(octokit, accountCreationDate),
]); ]);
console.log("repoData", repoData.user.repositoriesContributedTo.nodes);
let starCount = 0; let starCount = 0;
let forkCount = 0; let forkCount = 0;
for (const repo of repoData.user.repositories.nodes) { for (const repo of repoData.user.repositories.nodes) {
@@ -329,10 +361,20 @@ try {
const contributorStatsPromises = []; const contributorStatsPromises = [];
const viewCountPromises = []; const viewCountPromises = [];
for (const repo of repoData.user.repositories.nodes) { for (const repo of repoData.user.repositories.nodes) {
contributorStatsPromises.push( if (repo.name) {
getReposContributorsStats(octokit, username, repo.name) contributorStatsPromises.push(
); getReposContributorsStats(octokit, username, repo.name)
viewCountPromises.push(getReposViewCount(octokit, username, repo.name)); );
viewCountPromises.push(getReposViewCount(octokit, username, repo.name));
}
}
for (const repo of repoData.user.repositoriesContributedTo.nodes) {
if (repo.name) {
contributorStatsPromises.push(
getReposContributorsStats(octokit, username, repo.name)
);
}
} }
const contributorStats = (await Promise.all(contributorStatsPromises)) const contributorStats = (await Promise.all(contributorStatsPromises))