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

11

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