From 4353f6336a538ec41bb3e385b9429f02551c4e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Wed, 8 Jul 2015 09:17:58 +0300 Subject: [PATCH] Display only first 50 authors --- lib/index.js | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/lib/index.js b/lib/index.js index 523144a..a006e13 100644 --- a/lib/index.js +++ b/lib/index.js @@ -292,6 +292,24 @@ GitStats.ansiCalendar = function (data, callback) { return GitStats; }; +GitStats.authors = function (options, callback) { + var repo = new Gry(options.repo); + repo.exec("shortlog -s -n --all", function (err, stdout) { + if (err) { return callback(err); } + lines = stdout.split("\n"); + pieData = stdout.split("\n").map(function (c) { + var splits = c.split("\t").map(function (cc) { + return cc.trim(); + }); + return { + value: parseInt(splits[0]) + , label: splits[1] + }; + }); + callback(null, pieData); + }); +}; + GitStats.authorsPie = function (options, callback) { if (typeof options === "string") { options = { @@ -312,21 +330,22 @@ GitStats.authorsPie = function (options, callback) { , pieData = [] ; - repo.exec("shortlog -s -n --all", function (err, stdout) { + GitStats.authors(options, function (err, authors) { if (err) { return callback(err); } - lines = stdout.split("\n"); - - pieData = stdout.split("\n").map(function (c) { - var splits = c.split("\t").map(function (cc) { - return cc.trim(); - }); - return { - value: parseInt(splits[0]) - , label: splits[1] + if (authors.length > 50) { + var others = { + value: authors.slice(50).reduce(function (a, b) { + debugger + return a + b.value; + }, 0) + , label: "Others" }; - }); + debugger + authors = authors.slice(0, 50); + authors.push(others); + } - pie = new CliPie(options.radius, pieData, { + pie = new CliPie(options.radius, authors, { legend: true , flat: true , no_ansi: options.no_ansi