Fix challenge map display for loopback updated models. Update loopback migration script to auto complete and catch all records.
This commit is contained in:
@ -1,10 +1,10 @@
|
|||||||
/* eslint-disable no-process-exit */
|
/* eslint-disable no-process-exit */
|
||||||
require('dotenv').load();
|
require('dotenv').load();
|
||||||
var Rx = require('rx'),
|
var Rx = require('rx'),
|
||||||
uuid = require('node-uuid'),
|
uuid = require('node-uuid'),
|
||||||
assign = require('lodash/object/assign'),
|
assign = require('lodash/object/assign'),
|
||||||
mongodb = require('mongodb'),
|
mongodb = require('mongodb'),
|
||||||
secrets = require('../config/secrets');
|
secrets = require('../config/secrets');
|
||||||
|
|
||||||
var MongoClient = mongodb.MongoClient;
|
var MongoClient = mongodb.MongoClient;
|
||||||
|
|
||||||
@ -31,6 +31,7 @@ function createConnection(URI) {
|
|||||||
return observer.onError(err);
|
return observer.onError(err);
|
||||||
}
|
}
|
||||||
observer.onNext(database);
|
observer.onNext(database);
|
||||||
|
observer.onCompleted();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -47,6 +48,7 @@ function createQuery(db, collection, options, batchSize) {
|
|||||||
return observer.onError(err);
|
return observer.onError(err);
|
||||||
}
|
}
|
||||||
if (!doc) {
|
if (!doc) {
|
||||||
|
console.log('onCompleted');
|
||||||
return observer.onCompleted();
|
return observer.onCompleted();
|
||||||
}
|
}
|
||||||
observer.onNext(doc);
|
observer.onNext(doc);
|
||||||
@ -154,7 +156,7 @@ var storyCount = dbObservable
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
.flatMap(function(dats) {
|
.flatMap(function(dats) {
|
||||||
return insertMany(dats.db, 'stories', dats.stories, { w: 1 });
|
return insertMany(dats.db, 'story', dats.stories, { w: 1 });
|
||||||
})
|
})
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
@ -168,16 +170,18 @@ Rx.Observable.combineLatest(
|
|||||||
userCount: userCount * 20,
|
userCount: userCount * 20,
|
||||||
storyCount: storyCount * 20
|
storyCount: storyCount * 20
|
||||||
};
|
};
|
||||||
}
|
})
|
||||||
)
|
|
||||||
.subscribe(
|
.subscribe(
|
||||||
function(countObj) {
|
function(countObj) {
|
||||||
count = countObj;
|
console.log('next');
|
||||||
},
|
count = countObj;
|
||||||
function(err) {
|
},
|
||||||
console.error('an error occured', err, err.stack);
|
function(err) {
|
||||||
},
|
console.error('an error occured', err, err.stack);
|
||||||
function() {
|
},
|
||||||
console.log('finished with ', count);
|
function() {
|
||||||
}
|
|
||||||
);
|
console.log('finished with ', count);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
@ -29,7 +29,7 @@ module.exports = function(app) {
|
|||||||
|
|
||||||
var completedChallengeList = noDuplicatedChallenges
|
var completedChallengeList = noDuplicatedChallenges
|
||||||
.map(function(challenge) {
|
.map(function(challenge) {
|
||||||
return challenge.id;
|
return (challenge.id || challenge._id); // backwards compatibility
|
||||||
});
|
});
|
||||||
var challengeList = utils.
|
var challengeList = utils.
|
||||||
getChallengeMapForDisplay(completedChallengeList);
|
getChallengeMapForDisplay(completedChallengeList);
|
||||||
@ -37,7 +37,8 @@ module.exports = function(app) {
|
|||||||
Object.keys(challengeList).forEach(function(key) {
|
Object.keys(challengeList).forEach(function(key) {
|
||||||
challengeList[key].completed = challengeList[key]
|
challengeList[key].completed = challengeList[key]
|
||||||
.challenges.filter(function(elem) {
|
.challenges.filter(function(elem) {
|
||||||
return completedChallengeList.indexOf(elem.id) > -1;
|
return completedChallengeList.indexOf(elem.id || elem._id) > -1;
|
||||||
|
//backwards compatibility hack
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ var _ = require('lodash'),
|
|||||||
crypto = require('crypto'),
|
crypto = require('crypto'),
|
||||||
nodemailer = require('nodemailer'),
|
nodemailer = require('nodemailer'),
|
||||||
moment = require('moment'),
|
moment = require('moment'),
|
||||||
debug = require('debug')('freecc:cntr:userController'),
|
//debug = require('debug')('freecc:cntr:userController'),
|
||||||
|
|
||||||
secrets = require('../../config/secrets');
|
secrets = require('../../config/secrets');
|
||||||
|
|
||||||
@ -123,15 +123,12 @@ module.exports = function(app) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function returnUser (req, res, next) {
|
function returnUser (req, res, next) {
|
||||||
debug(req.params.username);
|
|
||||||
User.findOne(
|
User.findOne(
|
||||||
{ where: { 'username': req.params.username.toLowerCase() } },
|
{ where: { 'username': req.params.username.toLowerCase() } },
|
||||||
function(err, user) {
|
function(err, user) {
|
||||||
if (err) {
|
if (err) {
|
||||||
debug('Username err: ', err);
|
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
debug(user);
|
|
||||||
if (user) {
|
if (user) {
|
||||||
user.progressTimestamps =
|
user.progressTimestamps =
|
||||||
user.progressTimestamps.sort(function(a, b) {
|
user.progressTimestamps.sort(function(a, b) {
|
||||||
|
@ -83,7 +83,7 @@ block content
|
|||||||
.col-xs-12
|
.col-xs-12
|
||||||
ol
|
ol
|
||||||
for challenge in challengeBlock.challenges
|
for challenge in challengeBlock.challenges
|
||||||
if completedChallengeList.indexOf(challenge.id) > -1
|
if completedChallengeList.indexOf(challenge.id || challenge._id) > -1
|
||||||
.row
|
.row
|
||||||
.hidden-xs.col-sm-3.col-md-2.text-primary.ion-checkmark-circled.padded-ionic-icon.text-center.large-p.negative-10
|
.hidden-xs.col-sm-3.col-md-2.text-primary.ion-checkmark-circled.padded-ionic-icon.text-center.large-p.negative-10
|
||||||
.col-xs-12.col-sm-9.col-md-10
|
.col-xs-12.col-sm-9.col-md-10
|
||||||
|
Reference in New Issue
Block a user