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

View file

@ -1175,15 +1175,15 @@ GitStats.prototype.authors = function (options, callback) {
*/
GitStats.prototype.authorsPie = function (options, callback) {
const radius = Math.round(process.stdout.rows / 2) || 20;
if (typeof options === "string") {
options = {
repo: options
};
}
options = Ul.merge(options, { radius });
options = Ul.merge(options, {
radius: process.stdout.rows / 2 || 20
});
if (!IsThere(options.repo)) {
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) {
const maxAuthors = 2 * options.radius;
if (err) { return callback(err); }
if (authors.length > radius) {
if (authors.length > maxAuthors) {
var others = {
value: authors.slice(radius).reduce(function (a, b) {
value: authors.slice(maxAuthors).reduce(function (a, b) {
return a + b.value;
}, 0)
, label: "Others"
};
authors = authors.slice(0, radius);
authors = authors.slice(0, maxAuthors);
authors.push(others);
}