remove comments from migration

pull/18182/head
Berkeley Martinez 2015-08-05 10:47:08 -07:00
parent 9b72e03c76
commit 688bfd6137
1 changed files with 5 additions and 23 deletions

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();
}); });
@ -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(