mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2024-12-22 05:12:11 +01:00
Display only first 50 authors
This commit is contained in:
parent
68eb6235a7
commit
4353f6336a
1 changed files with 31 additions and 12 deletions
43
lib/index.js
43
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
|
||||
|
|
Loading…
Reference in a new issue