mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2024-12-22 13:22:11 +01:00
Handle the input data in record method
This commit is contained in:
parent
0622a48333
commit
d04935e340
1 changed files with 17 additions and 4 deletions
21
lib/index.js
21
lib/index.js
|
@ -109,8 +109,7 @@ GitStats.prototype.record = function (data, callback) {
|
||||||
delete data.url;
|
delete data.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get stats
|
function modify (err, stats) {
|
||||||
self.get(function (err, stats) {
|
|
||||||
|
|
||||||
var commits = stats.commits
|
var commits = stats.commits
|
||||||
, day = data.date.format(DATE_FORMAT)
|
, day = data.date.format(DATE_FORMAT)
|
||||||
|
@ -119,8 +118,22 @@ GitStats.prototype.record = function (data, callback) {
|
||||||
|
|
||||||
today[data.hash] = 1;
|
today[data.hash] = 1;
|
||||||
|
|
||||||
self.save(stats, callback);
|
if (data.save === false) {
|
||||||
});
|
callback(null, stats);
|
||||||
|
} else {
|
||||||
|
self.save(stats, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if we have input data
|
||||||
|
if (data._data) {
|
||||||
|
return modify(null, data._data);
|
||||||
|
} else {
|
||||||
|
// Get stats
|
||||||
|
self.get(modify);
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue