mirror of
https://github.com/LukeHagar/stats-action.git
synced 2025-12-06 04:21:26 +00:00
Apply automatic changes
This commit is contained in:
committed by
github-actions[bot]
parent
275b00b091
commit
8427a7123e
135
dist/index.js
vendored
135
dist/index.js
vendored
@@ -45311,25 +45311,19 @@ async function getUsersStars(octokit, username) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
async function getReposContributorsStats(octokit, username, repo) {
|
async function getReposContributorsStats(octokit, username, repo) {
|
||||||
return octokit.rest.repos
|
const response = await octokit.rest.repos.getContributorsStats({
|
||||||
.getContributorsStats({
|
|
||||||
owner: username,
|
owner: username,
|
||||||
repo,
|
repo,
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
if (res.status === 202) {
|
|
||||||
setTimeout(() => {
|
|
||||||
return octokit.rest.repos.getContributorsStats({
|
|
||||||
owner: username,
|
|
||||||
repo,
|
|
||||||
});
|
|
||||||
}, 2000);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
throw new Error(`Failed to fetch data for repo ${repo}: ${error.message}`);
|
|
||||||
});
|
});
|
||||||
|
if (response.status === 202) {
|
||||||
|
// Retry after the specified delay
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 2 * 1000));
|
||||||
|
// Retry the request
|
||||||
|
return getReposContributorsStats(octokit, username, repo);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async function getReposViewCount(octokit, username, repo) {
|
async function getReposViewCount(octokit, username, repo) {
|
||||||
return octokit.rest.repos.getViews({
|
return octokit.rest.repos.getViews({
|
||||||
@@ -45382,42 +45376,63 @@ try {
|
|||||||
getTotalCommits(octokit, username),
|
getTotalCommits(octokit, username),
|
||||||
getContributionCollection(octokit, userDetails.data.created_at),
|
getContributionCollection(octokit, userDetails.data.created_at),
|
||||||
]);
|
]);
|
||||||
|
const viewCountPromises = [];
|
||||||
let starCount = 0;
|
let starCount = 0;
|
||||||
let forkCount = 0;
|
let forkCount = 0;
|
||||||
for (const repo of repoData.user.repositories.nodes) {
|
let contributorStats = [];
|
||||||
starCount += repo.stargazers.totalCount;
|
const repos = [
|
||||||
forkCount += repo.forkCount;
|
...repoData.user.repositories.nodes,
|
||||||
}
|
...repoData.user.repositoriesContributedTo.nodes,
|
||||||
const contributorStatsPromises = [];
|
];
|
||||||
const viewCountPromises = [];
|
for (const repo of repos) {
|
||||||
for (const repo of repoData.user.repositories.nodes) {
|
let repoOwner, repoName;
|
||||||
if (repo.name) {
|
if (repo.nameWithOwner) {
|
||||||
contributorStatsPromises.push(getReposContributorsStats(octokit, username, repo.name));
|
[repoOwner, repoName] = repo.nameWithOwner.split("/");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
repoOwner = username;
|
||||||
|
repoName = repo.name;
|
||||||
|
}
|
||||||
|
const repoContribStatsResp = await getReposContributorsStats(octokit, repoOwner, repoName);
|
||||||
|
let stats;
|
||||||
|
if (!Array.isArray(repoContribStatsResp.data)) {
|
||||||
|
console.log("RepoContribStats is not an array");
|
||||||
|
console.log(repoContribStatsResp);
|
||||||
|
stats = [repoContribStatsResp.data];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stats = repoContribStatsResp.data;
|
||||||
|
}
|
||||||
|
// console.log(stats);
|
||||||
|
const repoContribStats = stats.find((contributor) => contributor.author?.login === username);
|
||||||
|
// console.log(repoContribStats?.weeks);
|
||||||
|
if (repoContribStats?.weeks)
|
||||||
|
contributorStats.push(...repoContribStats.weeks);
|
||||||
|
if (repoOwner === username) {
|
||||||
viewCountPromises.push(getReposViewCount(octokit, username, repo.name));
|
viewCountPromises.push(getReposViewCount(octokit, username, repo.name));
|
||||||
|
starCount += repo.stargazers.totalCount;
|
||||||
|
forkCount += repo.forkCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const repo of repoData.user.repositoriesContributedTo.nodes) {
|
|
||||||
if (repo.name) {
|
|
||||||
contributorStatsPromises.push(getReposContributorsStats(octokit, username, repo.name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const contributorStats = (await Promise.allSettled(contributorStatsPromises))
|
|
||||||
.filter((entry) => entry !== null || entry !== undefined)
|
|
||||||
.map((entry) => {
|
|
||||||
if (entry.status === "rejected") {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return (Array.isArray(entry.value.data) ? entry.value.data : [entry.value.data])
|
|
||||||
.filter((contributor) => contributor.author?.login === userDetails.data.login)
|
|
||||||
.map((contributor) => contributor.weeks);
|
|
||||||
});
|
|
||||||
let linesOfCodeChanged = 0;
|
let linesOfCodeChanged = 0;
|
||||||
for (const repo of contributorStats) {
|
let addedLines = 0;
|
||||||
for (const week of repo) {
|
let deletedLines = 0;
|
||||||
for (const day of week) {
|
let changedLines = 0;
|
||||||
linesOfCodeChanged += (day.a || 0) + (day.d || 0) + (day.c || 0);
|
let testTotal = 0;
|
||||||
}
|
for (const week of contributorStats) {
|
||||||
|
if (week.a) {
|
||||||
|
testTotal += week.a;
|
||||||
|
addedLines += week.a;
|
||||||
}
|
}
|
||||||
|
if (week.d) {
|
||||||
|
testTotal += week.d;
|
||||||
|
deletedLines += week.d;
|
||||||
|
}
|
||||||
|
if (week.c) {
|
||||||
|
testTotal += week.c;
|
||||||
|
changedLines += week.c;
|
||||||
|
}
|
||||||
|
linesOfCodeChanged += (week.a || 0) + (week.d || 0) + (week.c || 0);
|
||||||
}
|
}
|
||||||
const viewCounts = await Promise.all(viewCountPromises);
|
const viewCounts = await Promise.all(viewCountPromises);
|
||||||
let repoViews = 0;
|
let repoViews = 0;
|
||||||
@@ -45449,6 +45464,36 @@ try {
|
|||||||
const allDays = contributionsCollection.contributionCalendar.weeks
|
const allDays = contributionsCollection.contributionCalendar.weeks
|
||||||
.map((w) => w.contributionDays)
|
.map((w) => w.contributionDays)
|
||||||
.flat(1);
|
.flat(1);
|
||||||
|
const tableData = [
|
||||||
|
{ name: "Name", value: userDetails.data.name || "" },
|
||||||
|
{ name: "Username", value: username },
|
||||||
|
{ name: "Repository Views", value: repoViews },
|
||||||
|
{ name: "Lines of Code Changed", value: linesOfCodeChanged },
|
||||||
|
{ name: "Total Commits", value: totalCommits.data.total_count },
|
||||||
|
{
|
||||||
|
name: "Total Pull Requests",
|
||||||
|
value: userData.user.pullRequests.totalCount,
|
||||||
|
},
|
||||||
|
{ name: "Code Byte Total", value: codeByteTotal },
|
||||||
|
{
|
||||||
|
name: "Top Languages",
|
||||||
|
value: topLanguages.map((lang) => lang.languageName).join(", "),
|
||||||
|
},
|
||||||
|
{ name: "Fork Count", value: forkCount },
|
||||||
|
{ name: "Star Count", value: starCount },
|
||||||
|
{
|
||||||
|
name: "Total Contributions",
|
||||||
|
value: contributionsCollection.contributionCalendar.totalContributions,
|
||||||
|
},
|
||||||
|
{ name: "Closed Issues", value: userData.viewer.closedIssues.totalCount },
|
||||||
|
{ name: "Open Issues", value: userData.viewer.openIssues.totalCount },
|
||||||
|
{ name: "Fetched At", value: fetchedAt },
|
||||||
|
];
|
||||||
|
console.table(tableData);
|
||||||
|
const tableDataString = tableData
|
||||||
|
.map((row) => `${row.name}: ${row.value}`)
|
||||||
|
.join("\n");
|
||||||
|
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setOutput("tableData", tableDataString);
|
||||||
(0,fs__WEBPACK_IMPORTED_MODULE_2__.writeFileSync)("github-user-stats.json", JSON.stringify({
|
(0,fs__WEBPACK_IMPORTED_MODULE_2__.writeFileSync)("github-user-stats.json", JSON.stringify({
|
||||||
name: userDetails.data.name || "",
|
name: userDetails.data.name || "",
|
||||||
username,
|
username,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "Luke Hagar",
|
"name": "Luke Hagar",
|
||||||
"username": "LukeHagar",
|
"username": "LukeHagar",
|
||||||
"repoViews": 1842,
|
"repoViews": 1902,
|
||||||
"linesOfCodeChanged": 633966,
|
"linesOfCodeChanged": 10702113,
|
||||||
"totalCommits": 1582,
|
"totalCommits": 1583,
|
||||||
"totalPullRequests": 48,
|
"totalPullRequests": 48,
|
||||||
"codeByteTotal": 12548750,
|
"codeByteTotal": 12550153,
|
||||||
"topLanguages": [
|
"topLanguages": [
|
||||||
{
|
{
|
||||||
"languageName": "Svelte",
|
"languageName": "Svelte",
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
{
|
{
|
||||||
"languageName": "TypeScript",
|
"languageName": "TypeScript",
|
||||||
"color": "#3178c6",
|
"color": "#3178c6",
|
||||||
"value": 3158843
|
"value": 3160246
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"languageName": "Makefile",
|
"languageName": "Makefile",
|
||||||
@@ -85,10 +85,10 @@
|
|||||||
],
|
],
|
||||||
"forkCount": 15,
|
"forkCount": 15,
|
||||||
"starCount": 113,
|
"starCount": 113,
|
||||||
"totalContributions": 1773,
|
"totalContributions": 1774,
|
||||||
"closedIssues": 12,
|
"closedIssues": 12,
|
||||||
"openIssues": 10,
|
"openIssues": 10,
|
||||||
"fetchedAt": 1709295395197,
|
"fetchedAt": 1709324155287,
|
||||||
"contributionData": [
|
"contributionData": [
|
||||||
{
|
{
|
||||||
"contributionCount": 1,
|
"contributionCount": 1,
|
||||||
@@ -15279,7 +15279,7 @@
|
|||||||
"date": "2024-02-29"
|
"date": "2024-02-29"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"contributionCount": 0,
|
"contributionCount": 1,
|
||||||
"date": "2024-03-01"
|
"date": "2024-03-01"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user