Bauke/tildes-issue-log
Bauke
/
tildes-issue-log
Archived
1
Fork 0

Add average issue/day and list of issues from each label

This commit is contained in:
Bauke 2018-06-24 23:24:21 +02:00
parent 9f03a72374
commit dd50451ae4
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 40 additions and 4 deletions

44
main.js
View File

@ -162,14 +162,19 @@ function createStatistics() {
statistics += `${opened.length} issues were opened and `
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 averageClosedHours
for (const file of closed) {
const issue = require(file.path)
const openedAt = new Date(issue.created_at)
const closedAt = new Date(issue.closed_at)
const diffDays = Math.floor((closedAt - openedAt) / (1000 * 60 * 60 * 24))
const diffHours = Math.floor((closedAt - openedAt) / (1000 * 60 * 60))
const diffDays = (closedAt - openedAt) / (1000 * 60 * 60 * 24)
const diffHours = (closedAt - openedAt) / (1000 * 60 * 60)
averageClosedDays = (typeof averageClosedDays === 'undefined')
? averageClosedDays = diffDays
@ -178,11 +183,42 @@ function createStatistics() {
? averageClosedHours = diffHours
: averageClosedHours += diffHours
}
averageClosedDays = Math.floor(averageClosedDays / closed.length)
averageClosedHours = Math.floor(averageClosedHours / closed.length)
averageClosedDays = (averageClosedDays / closed.length).toFixed(2)
averageClosedHours = (averageClosedHours / closed.length).toFixed(2)
statistics += `The average time to close issues was ${averageClosedDays} days `
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'})
}