mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2024-12-22 05:12: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;
|
||||
}
|
||||
|
||||
// Get stats
|
||||
self.get(function (err, stats) {
|
||||
function modify (err, stats) {
|
||||
|
||||
var commits = stats.commits
|
||||
, day = data.date.format(DATE_FORMAT)
|
||||
|
@ -119,8 +118,22 @@ GitStats.prototype.record = function (data, callback) {
|
|||
|
||||
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;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue