Improved the migration script.

Fixes #81.
This commit is contained in:
Ionică Bizău 2016-02-27 19:30:23 +02:00
parent 90846424cd
commit a5eeac9ac4
2 changed files with 6 additions and 7 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "git-stats", "name": "git-stats",
"version": "2.9.2", "version": "2.9.3",
"description": "Local git statistics including GitHub-like contributions calendars.", "description": "Local git statistics including GitHub-like contributions calendars.",
"main": "lib/index.js", "main": "lib/index.js",
"bin": { "bin": {

View file

@ -20,13 +20,11 @@ function migrate() {
Logger.log(e); Logger.log(e);
} }
if (data.commits) { data.commits = data.commits || {};
return; var newStats = { commits: data.commits };
} delete data.commits;
var newStats = { commits: {} };
Object.keys(data).forEach(function (day) { Object.keys(data).forEach(function (day) {
var cDay = newStats.commits[day] = {}; var cDay = newStats.commits[day] = newStats.commits[day] || {};
Object.keys(data[day]).map(function (c) { Object.keys(data[day]).map(function (c) {
Object.keys(data[day][c]).map(function (h) { Object.keys(data[day][c]).map(function (h) {
cDay[h] = 1; cDay[h] = 1;
@ -38,3 +36,4 @@ function migrate() {
} }
migrate(); migrate();