From ddeb1e28ff86a54b0396afc3271e2f7e9ffa3df4 Mon Sep 17 00:00:00 2001 From: Bauke Date: Mon, 25 Jun 2018 00:24:03 +0200 Subject: [PATCH] Add most frequent issue creators --- main.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index ee98d6f..0a6712f 100644 --- a/main.js +++ b/main.js @@ -189,6 +189,23 @@ function createStatistics() { statistics += `The average time to close issues was ${averageClosedDays} days ` statistics += `or ${averageClosedHours} hours.\n\n` + let _mostFrequent = {} + for (const file of opened) { + const issue = require(file.path) + if (typeof _mostFrequent[issue.author.username] === 'undefined') _mostFrequent[issue.author.username] = 1 + else _mostFrequent[issue.author.username]++ + } + + let mostFrequent = Object.keys(_mostFrequent) + mostFrequent.sort((a, b) => _mostFrequent[b] - _mostFrequent[a]) + mostFrequent = mostFrequent.slice(0, 3) + + statistics += 'Most frequent issue creators:\n\n' + for (const user of mostFrequent) { + statistics += `* [${user}](https://gitlab.com/${user}) ` + statistics += `with [${_mostFrequent[user]} issues created](https://gitlab.com/tildes/tildes/issues?state=all&author_username=${user}).\n` + } + let labels = {} for (const file of opened) { const issue = require(file.path) @@ -202,7 +219,7 @@ function createStatistics() { let labelsOrdered = {} Object.keys(labels).sort().forEach(label => labelsOrdered[label] = labels[label]) - statistics += 'Total amount of labels assigned to currently open issues:\n\n' + statistics += '\nTotal amount of labels assigned to currently open issues:\n\n' for (const label in labelsOrdered) { statistics += `* [${label}](https://gitlab.com/tildes/tildes/issues?state=opened&label_name%5B%5D=${label.replace(' ', '+')}): ${labels[label]} times.\n`