Commit 558b9985 authored by 陈家荣's avatar 陈家荣

11

parent 1489d5fb
......@@ -703,12 +703,36 @@ router.get('/thread/updateConmentFloor', function(req, res, next) {
], function (err, result) {
var asyncTasks = [];
result.items.forEach(function(doc) { //遍历文章
asyncTasks.push(function(callback) {
// console.log(doc);
asyncTasks.push(function(callback2) {
//获取文章所有一级评论,倒数排列
var conditions = {
thread: doc._id,
level: '1'
};
async.waterfall([
function(callback) {
var comments = doc.comments;
//获取所有评论
forumCommentService.count(conditions, function(err, count) {
if (err) {
console.log(err);
callback(err, null);
} else {
callback(null, count);
}
});
},
function(count, callback) {
//获取所有评论
forumCommentService.getAllComment(conditions, 1, count, function(err, results) {
if (err) {
console.log(err);
callback(err, null);
} else {
callback(null, results.items);
}
});
},
function(comments, callback) {
comments = _.sortBy(comments, function(comment){
return comment.created;
});
......
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 to comment