From 8483f29b23d832e2a88d8321fd5e7ce7517f7c45 Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Wed, 1 Sep 2021 17:04:39 -0700 Subject: [PATCH] add stats on activity in last 24 hours --- scripts/stats/index.js | 24 ++++++++++++++++++++++-- scripts/stats/stats.csv | 4 ++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/scripts/stats/index.js b/scripts/stats/index.js index f13f1be2e..a621bfa3b 100644 --- a/scripts/stats/index.js +++ b/scripts/stats/index.js @@ -65,19 +65,39 @@ export async function run() { const twentyFourHoursAgo = new Date(); twentyFourHoursAgo.setDate(twentyFourHoursAgo.getDate() - 1); - const pulls = await octokit.paginate('GET /repos/{owner}/{repo}/pulls', { + const allIssues = await octokit.paginate('GET /repos/{owner}/{repo}/issues', { owner, repo, }); - const issues = await octokit.paginate('GET /repos/{owner}/{repo}/issues', { + const issues = allIssues.filter((iss) => !iss.pull_request); + const pulls = allIssues.filter((iss) => iss.pull_request); + + const allIssuesLastTwentyFourHours = await octokit.paginate('GET /repos/{owner}/{repo}/issues', { owner, repo, + state: 'all', + per_page: 100, + since: twentyFourHoursAgo.toISOString(), }); + const issuesLastTwentyFourHours = allIssuesLastTwentyFourHours.filter((iss) => new Date(iss.created_at) > twentyFourHoursAgo && !iss.pull_request); + const pullsLastTwentyFourHours = allIssuesLastTwentyFourHours.filter((iss) => new Date(iss.created_at) > twentyFourHoursAgo && iss.pull_request); + + console.log(issuesLastTwentyFourHours, pullsLastTwentyFourHours); const entry = [ // Date (Human Readable) `"${new Date().toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })}"`, // Commits in last 24 hours (await countCommits(twentyFourHoursAgo)).length, + // New Issues(All) in last 24 hours + issuesLastTwentyFourHours.length, + // New Issues(Bugs) in last 24 hours + issuesLastTwentyFourHours.filter((iss) => iss.title.startsWith('🐛 BUG:')).length, + // New Issues(RFC) in last 24 hours + issuesLastTwentyFourHours.filter((iss) => iss.title.startsWith('💡 RFC:')).length, + // New Issues(Docs) in last 24 hours + issuesLastTwentyFourHours.filter((iss) => iss.title.startsWith('📘 DOC:')).length, + // New Pull Requests in last 24 hours + pullsLastTwentyFourHours.length, // Pull requests pulls.length, // Open Issues diff --git a/scripts/stats/stats.csv b/scripts/stats/stats.csv index d415326cd..caf2e7561 100644 --- a/scripts/stats/stats.csv +++ b/scripts/stats/stats.csv @@ -1,2 +1,2 @@ -Date,Commits (24hr),Open PRs,Open Issues,Bugs: Needs Triage,Bugs: Accepted,RFC: Needs Discussion,RFC: In Progress,RFC: Accepted,Date (ISO) -"Wednesday, September 1, 2021",10,10,172,3,64,15,18,12,"2021-09-01T12:04:47.572Z" +Date,Commits (24hr),Issues (24hr),Issues:BUG (24hr),Issues:RFC (24hr),Issues:DOC (24hr),PRs (24hr),Open PRs,Open Issues,Bugs: Needs Triage,Bugs: Accepted,RFC: Needs Discussion,RFC: In Progress,RFC: Accepted,Date (ISO) +"Wednesday, September 1, 2021",21,4,3,1,0,8,7,166,3,54,36,0,12,"2021-09-02T00:02:50.708Z"