Display only first 50 authors

This commit is contained in:
Ionică Bizău 2015-07-08 09:17:58 +03:00
parent 68eb6235a7
commit 4353f6336a

View file

@ -292,6 +292,24 @@ GitStats.ansiCalendar = function (data, callback) {
return GitStats; 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) { GitStats.authorsPie = function (options, callback) {
if (typeof options === "string") { if (typeof options === "string") {
options = { options = {
@ -312,21 +330,22 @@ GitStats.authorsPie = function (options, callback) {
, pieData = [] , pieData = []
; ;
repo.exec("shortlog -s -n --all", function (err, stdout) { GitStats.authors(options, function (err, authors) {
if (err) { return callback(err); } if (err) { return callback(err); }
lines = stdout.split("\n"); if (authors.length > 50) {
var others = {
pieData = stdout.split("\n").map(function (c) { value: authors.slice(50).reduce(function (a, b) {
var splits = c.split("\t").map(function (cc) { debugger
return cc.trim(); return a + b.value;
}); }, 0)
return { , label: "Others"
value: parseInt(splits[0])
, label: splits[1]
}; };
}); debugger
authors = authors.slice(0, 50);
authors.push(others);
}
pie = new CliPie(options.radius, pieData, { pie = new CliPie(options.radius, authors, {
legend: true legend: true
, flat: true , flat: true
, no_ansi: options.no_ansi , no_ansi: options.no_ansi