-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to list CG that may be considered for closure
- Loading branch information
1 parent
64444e8
commit e61ffb9
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const fs = require("fs/promises"); | ||
|
||
function uniq(x, i, arr) { | ||
return arr.findIndex(xx => xx.id === x.id) === i; | ||
} | ||
|
||
function cleanGroupDescription(g) { | ||
return { | ||
id: g.id, | ||
name: g.name, | ||
link: g.link, | ||
reason: g.reason, | ||
chairs: g.chairs | ||
}; | ||
} | ||
|
||
// Whether a group is more than ~6 months old | ||
function notNew(g) { | ||
const created = new Date(g.created); | ||
return (new Date() - created) > 3600*24*1000*180; | ||
} | ||
|
||
const activities = ["lists", "repository", "wiki"]; | ||
|
||
const documentReason = reason => x => { return {...x, reason};}; | ||
|
||
const lastSixMonths = (() => { | ||
let cur = new Date(); | ||
let months = []; | ||
for (let i = 0 ; i < 6; i++) { | ||
months.push(`${cur.getFullYear()}-${("" + (cur.getMonth() + 1)).padStart(2, '0')}`); | ||
cur.setMonth(cur.getMonth() - 1); | ||
} | ||
return months; | ||
})(); | ||
|
||
(async function() { | ||
const {data} = JSON.parse(await fs.readFile("report.json")); | ||
|
||
const cgs = data.filter(x => x.type === "cg"); | ||
let candidates = []; | ||
|
||
candidates = candidates.concat(cgs.filter(x => x.participants <= 3).map(documentReason("fewer than 3 participants"))); | ||
|
||
const lowActivityCgs = cgs.filter(cg => { | ||
let activityLevel = 0; | ||
for (let a of Object.keys(cg.activity).filter(a => activities.includes(a))) { | ||
activityLevel += Object.keys(cg.activity[a]) | ||
.filter(m => lastSixMonths.includes(m)) | ||
.reduce((acc, m) => acc += cg.activity[a][m], 0); | ||
} | ||
return activityLevel <= 5; | ||
}).map(documentReason("fewer than 5 events in the past 6 months")); | ||
|
||
candidates = candidates.concat(lowActivityCgs); | ||
|
||
candidates = candidates.filter(uniq).filter(notNew); | ||
|
||
console.log(JSON.stringify(candidates.map(cleanGroupDescription), null, 2)); | ||
//console.log(candidates.length); | ||
})(); |