Get stats using the get method.

This commit is contained in:
Ionică Bizău 2015-01-26 09:58:03 +02:00
parent 704f1c9a42
commit c562c7ee3a
1 changed files with 4 additions and 2 deletions

View File

@ -25,9 +25,10 @@ var GitStats = module.exports = {};
* @return {undefined} * @return {undefined}
*/ */
GitStats.record = function (data, callback) { GitStats.record = function (data, callback) {
// Validate data
callback = callback || function (err) { if (err) throw err; }; callback = callback || function (err) { if (err) throw err; };
data = Object(data); data = Object(data);
if (typeof data.date === "string") { if (typeof data.date === "string") {
data.date = Moment(data.date, "DDD MMM dd HH:mm:ss YYYY"); data.date = Moment(data.date, "DDD MMM dd HH:mm:ss YYYY");
} }
@ -44,7 +45,8 @@ GitStats.record = function (data, callback) {
return callback(new Error("Invalid url field.")); return callback(new Error("Invalid url field."));
} }
FsExtra.readJSON(STORE_PATH, function (err, stats) { // Get stats
GitStats.get(function (err, stats) {
stats = stats || {}; stats = stats || {};
var day = data.date.format("MMM DDD dd, YYYY") var day = data.date.format("MMM DDD dd, YYYY")
, today = stats[day] = Object(stats[day]) , today = stats[day] = Object(stats[day])