Add average issue/day and list of issues from each label
This commit is contained in:
parent
9f03a72374
commit
dd50451ae4
44
main.js
44
main.js
|
@ -162,14 +162,19 @@ function createStatistics() {
|
||||||
statistics += `${opened.length} issues were opened and `
|
statistics += `${opened.length} issues were opened and `
|
||||||
statistics += `${closed.length} issues were closed.\n\n`
|
statistics += `${closed.length} issues were closed.\n\n`
|
||||||
|
|
||||||
|
const averageOpenPerDay = (opened.length / 30).toFixed(2)
|
||||||
|
const averageClosePerDay = (closed.length / 30).toFixed(2)
|
||||||
|
statistics += `An average of ${averageOpenPerDay} issues were opened `
|
||||||
|
statistics += `and ${averageClosePerDay} issues were closed each day.\n\n`
|
||||||
|
|
||||||
let averageClosedDays
|
let averageClosedDays
|
||||||
let averageClosedHours
|
let averageClosedHours
|
||||||
for (const file of closed) {
|
for (const file of closed) {
|
||||||
const issue = require(file.path)
|
const issue = require(file.path)
|
||||||
const openedAt = new Date(issue.created_at)
|
const openedAt = new Date(issue.created_at)
|
||||||
const closedAt = new Date(issue.closed_at)
|
const closedAt = new Date(issue.closed_at)
|
||||||
const diffDays = Math.floor((closedAt - openedAt) / (1000 * 60 * 60 * 24))
|
const diffDays = (closedAt - openedAt) / (1000 * 60 * 60 * 24)
|
||||||
const diffHours = Math.floor((closedAt - openedAt) / (1000 * 60 * 60))
|
const diffHours = (closedAt - openedAt) / (1000 * 60 * 60)
|
||||||
|
|
||||||
averageClosedDays = (typeof averageClosedDays === 'undefined')
|
averageClosedDays = (typeof averageClosedDays === 'undefined')
|
||||||
? averageClosedDays = diffDays
|
? averageClosedDays = diffDays
|
||||||
|
@ -178,11 +183,42 @@ function createStatistics() {
|
||||||
? averageClosedHours = diffHours
|
? averageClosedHours = diffHours
|
||||||
: averageClosedHours += diffHours
|
: averageClosedHours += diffHours
|
||||||
}
|
}
|
||||||
averageClosedDays = Math.floor(averageClosedDays / closed.length)
|
averageClosedDays = (averageClosedDays / closed.length).toFixed(2)
|
||||||
averageClosedHours = Math.floor(averageClosedHours / closed.length)
|
averageClosedHours = (averageClosedHours / closed.length).toFixed(2)
|
||||||
|
|
||||||
statistics += `The average time to close issues was ${averageClosedDays} days `
|
statistics += `The average time to close issues was ${averageClosedDays} days `
|
||||||
statistics += `or ${averageClosedHours} hours.\n\n`
|
statistics += `or ${averageClosedHours} hours.\n\n`
|
||||||
|
|
||||||
|
let labels = {}
|
||||||
|
for (const file of opened) {
|
||||||
|
const issue = require(file.path)
|
||||||
|
if (issue.closed_at !== null) continue
|
||||||
|
for (const label of issue.labels) {
|
||||||
|
if (typeof labels[label] === 'undefined') labels[label] = 1
|
||||||
|
else labels[label]++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
statistics += 'Total amount of labels assigned to currently open issues:\n'
|
||||||
|
|
||||||
|
for (const label in labels) {
|
||||||
|
statistics += `* [${label}](https://gitlab.com/tildes/tildes/issues?state=opened&label_name%5B%5D=${label.replace(' ', '+')}): ${labels[label]} times.\n`
|
||||||
|
}
|
||||||
|
|
||||||
|
labels = {}
|
||||||
|
for (const file of closed) {
|
||||||
|
const issue = require(file.path)
|
||||||
|
for (const label of issue.labels) {
|
||||||
|
if (typeof labels[label] === 'undefined') labels[label] = 1
|
||||||
|
else labels[label]++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
statistics += '\nTotal amount of labels assigned to closed issues:\n'
|
||||||
|
|
||||||
|
for (const label in labels) {
|
||||||
|
statistics += `* [${label}](https://gitlab.com/tildes/tildes/issues?state=closed&label_name%5B%5D=${label.replace(' ', '+')}): ${labels[label]} times.\n`
|
||||||
|
}
|
||||||
|
|
||||||
fs.writeFileSync(path.join(__dirname, year, month, 'statistics.md'), statistics, {encoding: 'UTF-8'})
|
fs.writeFileSync(path.join(__dirname, year, month, 'statistics.md'), statistics, {encoding: 'UTF-8'})
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue