Repository navigation
Expand file tree
/
Copy pathcompute_stats.js
More file actions
41 lines (34 loc) · 1.46 KB
/
Copy pathcompute_stats.js
File metadata and controls
41 lines (34 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
async function main()
{
const fs = await import('node:fs');
const path = await import('node:path');
const reportPath = path.join(process.cwd(), 'pr-data-report.json');
const prData = JSON.parse(fs.readFileSync(reportPath, 'utf-8'));
const orgCounts = {};
const monthlyCounts = {};
prData.members.forEach(m => {
const allPrs = [...(m.prs || []), ...(m.gsocPRList || [])];
allPrs.forEach(pr => {
if (!pr.repo) return;
const org = pr.repo.split('/')[0];
if (!orgCounts[org]) orgCounts[org] = { merged: 0, open: 0, closed: 0, total: 0 };
orgCounts[org].total++;
if (pr.state === 'merged') orgCounts[org].merged++;
if (pr.state === 'open') orgCounts[org].open++;
if (pr.state === 'closed') orgCounts[org].closed++;
if (pr.date && pr.state === 'merged') {
const date = new Date(pr.date);
const monthYear = date.toLocaleString('default', { month: 'short', year: 'numeric' });
if (!monthlyCounts[monthYear]) monthlyCounts[monthYear] = 0;
monthlyCounts[monthYear]++;
}
});
});
console.log("Org Counts:");
Object.entries(orgCounts).sort((a,b) => b[1].total - a[1].total).forEach(([org, counts]) => {
console.log(`${org}: ${JSON.stringify(counts)}`);
});
console.log("\nMonthly Counts:");
console.log(monthlyCounts);
}
main().catch(console.error);