fixed problem with missing students in office admin list

parent 4ba9dd64
Showing with 3 additions and 3 deletions
...@@ -259,6 +259,7 @@ module.exports = { ...@@ -259,6 +259,7 @@ module.exports = {
function (err) { // loop has end function (err) { // loop has end
// Get all students from the office if user is administrator // Get all students from the office if user is administrator
if (sup.office && sup.office.admin == sup.id) { if (sup.office && sup.office.admin == sup.id) {
var officeStudents;
Student.find({ office: sup.office.id }).populate('lastInstruction') Student.find({ office: sup.office.id }).populate('lastInstruction')
.then(function (officeStudents) { .then(function (officeStudents) {
...@@ -268,14 +269,13 @@ module.exports = { ...@@ -268,14 +269,13 @@ module.exports = {
student.current_instruction = student.lastInstruction[0] ? student.lastInstruction[0].ins_name : "no_instruction"; student.current_instruction = student.lastInstruction[0] ? student.lastInstruction[0].ins_name : "no_instruction";
return student; return student;
}); });
l.concat(officeStudents); l = l.concat(officeStudents);
callback(null, lodash.uniq(l, false, 'id')); callback(err, lodash.uniq(l, false, 'id'));
}) })
.catch(function (err) { .catch(function (err) {
callback(err, l); callback(err, l);
}); });
} }
callback(err, l);
}); // end async.eachSeries }); // end async.eachSeries
}) })
.catch((err) => { .catch((err) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment