From faeff7b1edcff161ec154abdc0c96e0a1547f339 Mon Sep 17 00:00:00 2001 From: terakilobyte Date: Mon, 15 Jun 2015 18:10:48 -0400 Subject: [PATCH 1/6] Ensure build process is part of npm install --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index ddad9d678f2..7eff9f3f2ee 100644 --- a/index.js +++ b/index.js @@ -28,7 +28,7 @@ var CompletionMonitor = function() { Challenge.destroyAll(function(err, info) { if (err) { - console.err(err); + console.error(err); } else { console.log('Deleted ', info); } From 643aa30ceab8c30cbaa1ab678c2b0e8be2060a49 Mon Sep 17 00:00:00 2001 From: terakilobyte Date: Mon, 15 Jun 2015 18:59:56 -0400 Subject: [PATCH 2/6] Fix json typo --- challenges/basic-html5-and-css.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/challenges/basic-html5-and-css.json b/challenges/basic-html5-and-css.json index 3e0532d81a9..4640facb095 100644 --- a/challenges/basic-html5-and-css.json +++ b/challenges/basic-html5-and-css.json @@ -1758,8 +1758,8 @@ }, { "id": "bad87fee1348bd9aedc08830", - "name": "waypoint-use-html5-to-require-a-field", - "dashedName": "Waypoint: Use HTML5 to Require a Field", + "name": "Waypoint: Use HTML5 to Require a Field", + "dashedName": "waypoint-use-html5-to-require-a-field", "difficulty": 0.042, "description": [ "Make your text input a \"required\" field, so that your user can't submit the form without completing this field.", From d87dcd6ada1db5072e4932eb8beed7e7431f1b73 Mon Sep 17 00:00:00 2001 From: terakilobyte Date: Mon, 15 Jun 2015 19:12:48 -0400 Subject: [PATCH 3/6] Remove excess debug statements from flattenUser.js --- flattenUser.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/flattenUser.js b/flattenUser.js index fad529cea37..db107ade458 100644 --- a/flattenUser.js +++ b/flattenUser.js @@ -29,26 +29,21 @@ function createConnection(URI) { function createQuery(db, collection, options, batchSize) { return Rx.Observable.create(function (observer) { - console.log('Creating cursor...'); var cursor = db.collection(collection).find({}, options); cursor.batchSize(batchSize || 20); // Cursor.each will yield all doc from a batch in the same tick, // or schedule getting next batch on nextTick cursor.each(function (err, doc) { if (err) { - console.log(err); return observer.onError(err); } if (!doc) { - console.log('hit complete'); return observer.onCompleted(); } - console.log('calling onnext'); observer.onNext(doc); }); return Rx.Disposable.create(function () { - console.log('Disposing cursor...'); cursor.close(); }); }); @@ -101,7 +96,6 @@ var userSavesCount = users }) .flatMap(function(dats) { // bulk insert into new collection for loopback - console.log(dats); return insertMany(dats.db, 'user', dats.users, { w: 1 }); }) // count how many times insert completes @@ -147,7 +141,7 @@ Rx.Observable.merge( count += _count * 20; }, function(err) { - console.log('an error occured', err, err.stack); + console.error('an error occured', err, err.stack); }, function() { console.log('finished with %s documents processed', count); From 93dd65176c159e2c338b2a2171dfa43f6640f360 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Mon, 15 Jun 2015 16:47:50 -0700 Subject: [PATCH 4/6] rename flattenUser to loopbackMigration add stories migration to script --- flattenUser.js => loopbackMigration.js | 44 +++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) rename flattenUser.js => loopbackMigration.js (78%) diff --git a/flattenUser.js b/loopbackMigration.js similarity index 78% rename from flattenUser.js rename to loopbackMigration.js index db107ade458..75f89103370 100644 --- a/flattenUser.js +++ b/loopbackMigration.js @@ -16,6 +16,14 @@ var providers = [ 'linkedin' ]; +// create async console.logs +function debug() { + var args = [].slice.call(arguments); + process.nextTick(function() { + console.log.apply(console, args); + }); +} + function createConnection(URI) { return Rx.Observable.create(function(observer) { MongoClient.connect(URI, function(err, database) { @@ -33,6 +41,7 @@ function createQuery(db, collection, options, batchSize) { cursor.batchSize(batchSize || 20); // Cursor.each will yield all doc from a batch in the same tick, // or schedule getting next batch on nextTick + debug('opening cursor for %s', collection); cursor.each(function (err, doc) { if (err) { return observer.onError(err); @@ -44,6 +53,7 @@ function createQuery(db, collection, options, batchSize) { }); return Rx.Disposable.create(function () { + debug('closing cursor for %s', collection); cursor.close(); }); }); @@ -132,18 +142,42 @@ var userIdentityCount = users // count how many times insert completes .count(); -Rx.Observable.merge( +var storyCount = dbObservable + .flatMap(function(db) { + return createQuery(db, 'stories', {}); + }) + .bufferWithCount(20) + .withLatestFrom(dbObservable, function(stories, db) { + return { + stories: stories, + db: db + }; + }) + .flatMap(function(dats) { + return insertMany(dats.db, 'stories', dats.stories, { w: 1 }); + }) + .count(); + +Rx.Observable.combineLatest( userIdentityCount, - userSavesCount + userSavesCount, + storyCount, + function(userIdentCount, userCount, storyCount) { + return { + userIdentCount: userIdentCount * 20, + userCount: userCount * 20, + storyCount: storyCount * 20 + }; + } ) .subscribe( - function(_count) { - count += _count * 20; + function(countObj) { + count = countObj; }, function(err) { console.error('an error occured', err, err.stack); }, function() { - console.log('finished with %s documents processed', count); + console.log('finished with ', count); } ); From 092f8254ed6cd611aff8e7fa58f75252de22731f Mon Sep 17 00:00:00 2001 From: terakilobyte Date: Mon, 15 Jun 2015 20:53:43 -0400 Subject: [PATCH 5/6] Fix challenge map display for loopback updated models. Update loopback migration script to auto complete and catch all records. --- loopbackMigration.js | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/loopbackMigration.js b/loopbackMigration.js index 75f89103370..02dd993b9c8 100644 --- a/loopbackMigration.js +++ b/loopbackMigration.js @@ -1,10 +1,10 @@ /* eslint-disable no-process-exit */ require('dotenv').load(); var Rx = require('rx'), - uuid = require('node-uuid'), - assign = require('lodash/object/assign'), - mongodb = require('mongodb'), - secrets = require('../config/secrets'); + uuid = require('node-uuid'), + assign = require('lodash/object/assign'), + mongodb = require('mongodb'), + secrets = require('../config/secrets'); var MongoClient = mongodb.MongoClient; @@ -31,6 +31,7 @@ function createConnection(URI) { return observer.onError(err); } observer.onNext(database); + observer.onCompleted(); }); }); } @@ -47,6 +48,7 @@ function createQuery(db, collection, options, batchSize) { return observer.onError(err); } if (!doc) { + console.log('onCompleted'); return observer.onCompleted(); } observer.onNext(doc); @@ -154,7 +156,7 @@ var storyCount = dbObservable }; }) .flatMap(function(dats) { - return insertMany(dats.db, 'stories', dats.stories, { w: 1 }); + return insertMany(dats.db, 'story', dats.stories, { w: 1 }); }) .count(); @@ -168,16 +170,18 @@ Rx.Observable.combineLatest( userCount: userCount * 20, storyCount: storyCount * 20 }; - } -) + }) .subscribe( - function(countObj) { - count = countObj; - }, - function(err) { - console.error('an error occured', err, err.stack); - }, - function() { - console.log('finished with ', count); - } - ); + function(countObj) { + console.log('next'); + count = countObj; + }, + function(err) { + console.error('an error occured', err, err.stack); + }, + function() { + + console.log('finished with ', count); + process.exit(0); + } +); From bec1460d8279a1863034d5d54a34d7bdf36af2fb Mon Sep 17 00:00:00 2001 From: terakilobyte Date: Tue, 16 Jun 2015 08:36:54 -0400 Subject: [PATCH 6/6] Fix wikipedia viewer zipline naming --- challenges/ziplines.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/challenges/ziplines.json b/challenges/ziplines.json index f61a96280ef..3779c06ff7e 100644 --- a/challenges/ziplines.json +++ b/challenges/ziplines.json @@ -173,8 +173,8 @@ }, { "id": "bd7158d8c442eddfaeb5bd19", - "name": "zipline-wikipedia-viewer", - "dashedName": "Zipline: Wikipedia Viewer", + "name": "Zipline: Wikipedia Viewer", + "dashedName": "zipline-wikipedia-viewer", "difficulty": 1.05, "challengeSeed": ["126415131"], "description": [