Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 35 additions & 27 deletions compute_stats.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
const fs = require('fs');
const prData = JSON.parse(fs.readFileSync('/Users/sahityasingh/DevForge/pr-data-report.json', 'utf8'));
async function main()
{
const fs = await import('node:fs');
const path = await import('node:path');

const orgCounts = {};
const monthlyCounts = {};
const reportPath = path.join(process.cwd(), 'pr-data-report.json');
const prData = JSON.parse(fs.readFileSync(reportPath, 'utf-8'));

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++;
const orgCounts = {};
const monthlyCounts = {};

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]++;
}
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("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);
}

console.log("\nMonthly Counts:");
console.log(monthlyCounts);
main().catch(console.error);
2 changes: 1 addition & 1 deletion scripts/pr-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ async function main() {
};

// Save to file
const fs = require('fs');
const fs = await import('node:fs');
fs.writeFileSync('pr-data-report.json', JSON.stringify(outputData, null, 2));
console.log('\n\n📁 Full data saved to: pr-data-report.json');
}
Expand Down
Loading