fix: show more authors

This commit is contained in:
Jonah Lawrence 2022-03-29 02:20:20 +00:00
parent fe198b1018
commit 95176aeed0
No known key found for this signature in database
GPG Key ID: 613851A667DC08A3
1 changed files with 7 additions and 6 deletions

View File

@ -1175,15 +1175,15 @@ GitStats.prototype.authors = function (options, callback) {
*/ */
GitStats.prototype.authorsPie = function (options, callback) { GitStats.prototype.authorsPie = function (options, callback) {
const radius = Math.round(process.stdout.rows / 2) || 20;
if (typeof options === "string") { if (typeof options === "string") {
options = { options = {
repo: options repo: options
}; };
} }
options = Ul.merge(options, { radius }); options = Ul.merge(options, {
radius: process.stdout.rows / 2 || 20
});
if (!IsThere(options.repo)) { if (!IsThere(options.repo)) {
return callback(new Error("The repository folder doesn't exist.")); return callback(new Error("The repository folder doesn't exist."));
@ -1196,15 +1196,16 @@ GitStats.prototype.authorsPie = function (options, callback) {
; ;
self.authors(options, function (err, authors) { self.authors(options, function (err, authors) {
const maxAuthors = 2 * options.radius;
if (err) { return callback(err); } if (err) { return callback(err); }
if (authors.length > radius) { if (authors.length > maxAuthors) {
var others = { var others = {
value: authors.slice(radius).reduce(function (a, b) { value: authors.slice(maxAuthors).reduce(function (a, b) {
return a + b.value; return a + b.value;
}, 0) }, 0)
, label: "Others" , label: "Others"
}; };
authors = authors.slice(0, radius); authors = authors.slice(0, maxAuthors);
authors.push(others); authors.push(others);
} }