Merge branch 'staging' of github.com:FreeCodeCamp/freecodecamp into staging

This commit is contained in:
Quincy Larson
2015-08-05 11:58:09 -07:00
2 changed files with 17 additions and 35 deletions

View File

@ -259,7 +259,7 @@
"challengeSeed": [ "challengeSeed": [
"var firstName = \"Madeline\";", "var firstName = \"Madeline\";",
"", "",
"var thirdToLastLetterOfFirstName = firstName[firstName.length - 2];", "var thirdToLastLetterOfFirstName = firstName[firstName.length - 3];",
"", "",
"var lastName = \"Chen\";", "var lastName = \"Chen\";",
"", "",
@ -601,7 +601,7 @@
], ],
"challengeSeed": [ "challengeSeed": [
"var myArray = ['John', 23, ['dog', 3]];", "var myArray = ['John', 23, ['dog', 3]];",
"var removed = myArray;//This should be ['John'] and myArray should now be ['John', 23]", "var removed = myArray;//This should be ['John'] and myArray should now be [23, ['dog', 3]]",
"", "",
"", "",
"(function(y, z){return('myArray = ' + JSON.stringify(y) + ' & removed = ' + JSON.stringify(z));})(myArray, removed);" "(function(y, z){return('myArray = ' + JSON.stringify(y) + ' & removed = ' + JSON.stringify(z));})(myArray, removed);"
@ -725,9 +725,9 @@
"", "",
"Now that we have an objects we need to know how to add and remove properties from it", "Now that we have an objects we need to know how to add and remove properties from it",
"We add properties to objects like this", "We add properties to objects like this",
"<code>myObject['myProperty'] = \"myValue\";</code>", "<code>myObject.myProperty = \"myValue\";</code>",
"They can also be deleted like this", "They can also be deleted like this",
"<code>delete(myObject[\"myProperty\"]);</code>", "<code>delete(myObject.myProperty);</code>",
"Let's add the property bark", "Let's add the property bark",
"" ""
], ],
@ -752,7 +752,7 @@
" \"friends\": []", " \"friends\": []",
"};", "};",
"", "",
"//Let's add the property age to myDog", "//Let's add the property bark to myDog",
"", "",
"", "",
"//Now delete the property tails", "//Now delete the property tails",
@ -1027,7 +1027,7 @@
], ],
"tests":[ "tests":[
"assert(test === 2, 'Your RegEx should have found two numbers in the testString');", "assert(test === 2, 'Your RegEx should have found two numbers in the testString');",
"assert(editorValue.match(/\\/\\\\d\\+\\//gi), 'You should be using the following expression /\\d+/gi to find the numbers in the testString');" "assert(editor.getValue().match(/\\/\\\\d\\+\\//gi), 'You should be using the following expression /\\d+/gi to find the numbers in the testString');"
], ],
"challengeSeed":[ "challengeSeed":[
"var test = (function(){", "var test = (function(){",
@ -1058,7 +1058,7 @@
], ],
"tests":[ "tests":[
"assert(test === 7, 'Your RegEx should have found seven spaces in the testString');", "assert(test === 7, 'Your RegEx should have found seven spaces in the testString');",
"assert(editorValue.match(/\\/\\\\s\\+\\//gi), 'You should be using the following expression /\\s+/gi to find the spaces in the testString');" "assert(editor.getValue().match(/\\/\\\\s\\+\\//gi), 'You should be using the following expression /\\s+/gi to find the spaces in the testString');"
], ],
"challengeSeed":[ "challengeSeed":[
"var test = (function(){", "var test = (function(){",
@ -1087,7 +1087,7 @@
], ],
"tests":[ "tests":[
"assert(test === 36, 'Your RegEx should have found seven spaces in the testString');", "assert(test === 36, 'Your RegEx should have found seven spaces in the testString');",
"assert(editorValue.match(/\\/\\\\S\\/gi/gi), 'You should be using the following expression /\\S+/gi to find the spaces in the testString');" "assert(editor.getValue().match(/\\/\\\\S\\/gi/gi), 'You should be using the following expression /\\S+/gi to find the spaces in the testString');"
], ],
"challengeSeed":[ "challengeSeed":[
"var test = (function(){", "var test = (function(){",

View File

@ -38,13 +38,13 @@ function createConnection(URI) {
} }
function createQuery(db, collection, options, batchSize) { function createQuery(db, collection, options, batchSize) {
return Rx.Observable.create(function (observer) { return Rx.Observable.create(function(observer) {
var cursor = db.collection(collection).find({}, options); var cursor = db.collection(collection).find({}, options);
cursor.batchSize(batchSize || 20); cursor.batchSize(batchSize || 20);
// Cursor.each will yield all doc from a batch in the same tick, // Cursor.each will yield all doc from a batch in the same tick,
// or schedule getting next batch on nextTick // or schedule getting next batch on nextTick
debug('opening cursor for %s', collection); debug('opening cursor for %s', collection);
cursor.each(function (err, doc) { cursor.each(function(err, doc) {
if (err) { if (err) {
return observer.onError(err); return observer.onError(err);
} }
@ -55,7 +55,7 @@ function createQuery(db, collection, options, batchSize) {
observer.onNext(doc); observer.onNext(doc);
}); });
return Rx.Disposable.create(function () { return Rx.Disposable.create(function() {
debug('closing cursor for %s', collection); debug('closing cursor for %s', collection);
cursor.close(); cursor.close();
}); });
@ -86,13 +86,13 @@ var users = dbObservable
.map(function(user) { .map(function(user) {
// flatten user // flatten user
assign(user, user.portfolio, user.profile); assign(user, user.portfolio, user.profile);
return user;
})
.map(function(user) {
if (user.username) { if (user.username) {
return user; return user;
} }
user.username = 'fcc' + uuid.v4().slice(0, 8); user.username = 'fcc' + uuid.v4().slice(0, 8);
if (user.github) {
user.isGithubCool = true;
}
return user; return user;
}) })
.shareReplay(); .shareReplay();
@ -122,7 +122,7 @@ var userIdentityCount = users
return { return {
provider: provider, provider: provider,
externalId: user[provider], externalId: user[provider],
userId: user.id userId: user._id || user.id
}; };
}) })
.filter(function(ident) { .filter(function(ident) {
@ -161,33 +161,15 @@ var storyCount = dbObservable
}) })
.count(); .count();
var commentCount = dbObservable
.flatMap(function(db) {
return createQuery(db, 'comments', {});
})
.bufferWithCount(20)
.withLatestFrom(dbObservable, function(comments, db) {
return {
comments: comments,
db: db
};
})
.flatMap(function(dats) {
return insertMany(dats.db, 'comment', dats.comments, { w: 1 });
})
.count();
Rx.Observable.combineLatest( Rx.Observable.combineLatest(
userIdentityCount, userIdentityCount,
userSavesCount, userSavesCount,
storyCount, storyCount,
commentCount, function(userIdentCount, userCount, storyCount) {
function(userIdentCount, userCount, storyCount, commentCount) {
return { return {
userIdentCount: userIdentCount * 20, userIdentCount: userIdentCount * 20,
userCount: userCount * 20, userCount: userCount * 20,
storyCount: storyCount * 20, storyCount: storyCount * 20
commentCount: commentCount * 20
}; };
}) })
.subscribe( .subscribe(