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;
};
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