Handle the input data in record method

This commit is contained in:
Ionică Bizău 2015-09-13 17:44:40 +03:00
parent 0622a48333
commit d04935e340

View file

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