diff --git a/challenge-migration.js b/challenge-migration.js index 5c8fd015907..7ef359781fa 100644 --- a/challenge-migration.js +++ b/challenge-migration.js @@ -8,20 +8,6 @@ var bonfires = require('./bonfires.json'), oldUri='mongodb://localhost:27017/app30893198', coursewares = require('./coursewares.json'); -var counter = 0; -var offerings = 2; - -var CompletionMonitor = function() { - counter++; - console.log('call ' + counter); - - if (counter < offerings) { - return; - } else { - process.exit(0); - } -}; - MongoClient.connect(oldUri, function(err, database) { database.collection('users').find({}).batchSize(20).toArray(function(err, users) { diff --git a/index.js b/index.js index 3dbbf9d8699..8c46b77f685 100644 --- a/index.js +++ b/index.js @@ -17,18 +17,19 @@ var Nonprofit = app.models.Nonprofit; var Job = app.models.Job; var counter = 0; var challenges = getFilesFor('challenges'); -var offerings = 2 + challenges.length; -var CompletionMonitor = function() { +function completionMonitor() { + // Increment counter counter++; - console.log('call ' + counter); - if (counter < offerings) { - return; - } else { + // Exit if all challenges have been checked + if (counter > challenges.length) { process.exit(0); } -}; + + // Log where in the seed order we're currently at + console.log('Call: ' + counter + "/" + challenges.length); +} Challenge.destroyAll(function(err, info) { if (err) { @@ -66,7 +67,7 @@ Challenge.destroyAll(function(err, info) { console.log(err); } else { console.log('Successfully parsed %s', file); - CompletionMonitor(); + completionMonitor(); } } ); @@ -85,7 +86,7 @@ Nonprofit.destroyAll(function(err, info) { } else { console.log('Saved ', data); } - CompletionMonitor(); + completionMonitor(); console.log('nonprofits'); }); }); @@ -103,6 +104,6 @@ Job.destroyAll(function(err, info) { console.log('Saved ', data); } console.log('jobs'); - CompletionMonitor(); + completionMonitor(); }); });