From badc34373b4e474d9bf443e36e6bbe5669eb9556 Mon Sep 17 00:00:00 2001 From: nanalelfe Date: Mon, 25 Jul 2016 03:48:00 -0400 Subject: need pulL --- node_simple.js | 5 ++++- routes/user.js | 10 ++++++++-- views/user_profile_alt.hbs | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/node_simple.js b/node_simple.js index 0290519..426570a 100644 --- a/node_simple.js +++ b/node_simple.js @@ -330,7 +330,7 @@ exports.retrieve_userComments_history = function (username, callback) { // get a connection mongoFactory.getConnection(uri).then(function (db) { - + console.log("for Each here"); var solutions = db.collection('solutions'); var exams = db.collection('exams'); var mylist = []; @@ -350,8 +350,10 @@ exports.retrieve_userComments_history = function (username, callback) { _id: 0 }} ]).toArray(function (err, res) { + console.log("for Each here"); var finised = _.after(res.length, doCall); // execute "doCall" only after res.length # of attempts res.forEach(function (comment) { + console.log("for Each here"); exams.find( { _id: ObjectId(comment.exam_id) } ).toArray(function (err, docs) { // get the exam info comment.course_code = docs[0].course_code; comment.year = docs[0].year; @@ -363,6 +365,7 @@ exports.retrieve_userComments_history = function (username, callback) { }); function doCall() { + console.log("Am i inside the doCall()"); callback(true, mylist); console.log("IN NODE SIMPLE: " + mylist); } diff --git a/routes/user.js b/routes/user.js index b179236..b89ff2f 100644 --- a/routes/user.js +++ b/routes/user.js @@ -23,6 +23,7 @@ router.get('/user_profile', loggedIn, isUser, function(req, res, next) { var comments = []; var inbox = []; function getComments() { + console.log('in getComments'); return new Promise(function(resolve, reject) { dbFile.retrieve_userComments_history(req.user.user_name, function (success, object) { if (!success) { @@ -39,8 +40,10 @@ router.get('/user_profile', loggedIn, isUser, function(req, res, next) { }; comments.push(obj); comments.push(obj); - resolve(1); + } + + resolve(1); } else if (object.length){ comments = object; resolve(1); @@ -50,6 +53,7 @@ router.get('/user_profile', loggedIn, isUser, function(req, res, next) { }); } function getMail(){ + console.log('ing getMail'); return new Promise(function(resolve, reject) { dbFile.checkMailbox(req.user.user_name, function(success, error, data, message){ if (success) { @@ -74,10 +78,12 @@ router.get('/user_profile', loggedIn, isUser, function(req, res, next) { }); }); } - getComments().then(getMail).then(function () { + getComments().then(getMail).then(function (data) { + console.log('got here'); res.render('user_profile_alt', {comments : comments, inbox: inbox, csrfToken: req.csrfToken()}); }); + //res.render('user_profile_alt', {comments : comments, inbox: inbox, csrfToken: req.csrfToken()}); }); /* Adds a solution into the database, redirect to exam/question/solution page */ diff --git a/views/user_profile_alt.hbs b/views/user_profile_alt.hbs index 89680e9..2270d76 100644 --- a/views/user_profile_alt.hbs +++ b/views/user_profile_alt.hbs @@ -199,7 +199,7 @@ col-sm-offset-0 col-md-offset-3 col-lg-offset-3 toppad prf-details"> {{# each inbox }} - + {{ this.date }} {{ this.subject }} -- cgit v1.2.3