mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +00:00
script to report estimations (#4182)
* prototype * run in parallel * actually run on all projects
This commit is contained in:
parent
7a5694c15c
commit
c204e915b1
74
website/scripts/get-estimation-report.js
vendored
Normal file
74
website/scripts/get-estimation-report.js
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
module.exports = {
|
||||
|
||||
|
||||
friendlyName: 'Get estimation report',
|
||||
|
||||
|
||||
description: '',
|
||||
|
||||
|
||||
exits: {
|
||||
|
||||
success: {
|
||||
outputFriendlyName: 'Estimation report',
|
||||
outputType: {}
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
|
||||
fn: async function () {
|
||||
|
||||
sails.log('Getting estimation report...');
|
||||
|
||||
if (!sails.config.custom.githubAccessToken) {
|
||||
throw new Error('No GitHub access token configured! (Please set `sails.config.custom.githubAccessToken`.)');
|
||||
}//•
|
||||
|
||||
let baseHeaders = {
|
||||
'User-Agent': 'fleet story points',
|
||||
'Authorization': `token ${sails.config.custom.githubAccessToken}`
|
||||
};
|
||||
|
||||
let estimationReport = {};
|
||||
|
||||
// FUTURE: only look at particular projects here instead of all of them
|
||||
let projects = await sails.helpers.http.get(`https://api.github.com/orgs/fleetdm/projects`, {}, baseHeaders);
|
||||
// projects = projects.filter((project)=> Number(project.id) === 13160610);// « hack to try it w/ just one project
|
||||
|
||||
await sails.helpers.flow.simultaneouslyForEach(projects, async(project)=>{
|
||||
estimationReport[project.name] = {};
|
||||
let columns = await sails.helpers.http.get(`https://api.github.com/projects/${project.id}/columns`, {}, baseHeaders);
|
||||
await sails.helpers.flow.simultaneouslyForEach(columns, async(column)=>{
|
||||
// console.log('------',project.name, column.name);
|
||||
estimationReport[project.name][column.name] = 0;
|
||||
let cards = await sails.helpers.http.get(`https://api.github.com/projects/columns/${column.id}/cards`, {}, baseHeaders);
|
||||
await sails.helpers.flow.simultaneouslyForEach(cards, async(card)=>{
|
||||
|
||||
// Get the number of story points associated with this card.
|
||||
let numPoints = 0;
|
||||
if (!card.content_url) {
|
||||
// ignore "notes" (FUTURE: Maybe add some kind of sniffing for a prefix like "[5]")
|
||||
} else {
|
||||
let issue = await sails.helpers.http.get(card.content_url, {}, baseHeaders);
|
||||
let pointLabels = issue.labels.filter((label)=> Number(label.name) >= 1 && Number(label.name) < Infinity);
|
||||
if (pointLabels.length >= 2) { throw new Error(`Cannot have more than one story point label, but issue #${issue.id} seems to have more than one: ${_.pluck(pointLabels,'name')}`); }
|
||||
if (pointLabels.length === 0) {
|
||||
numPoints = 0;
|
||||
} else {
|
||||
numPoints = Number(pointLabels[0].name);
|
||||
}
|
||||
}
|
||||
// console.log(`${column.name} :: ${card.id} :: +${numPoints}`);
|
||||
estimationReport[project.name][column.name] += numPoints;
|
||||
});//∞
|
||||
});//∞
|
||||
});//∞
|
||||
|
||||
return estimationReport;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user