Commit c76dbf7f authored by 杨翌文's avatar 杨翌文

1111

parent 43704520
...@@ -722,22 +722,20 @@ function getSubThreads(doc, sort, callback) { ...@@ -722,22 +722,20 @@ function getSubThreads(doc, sort, callback) {
} }
function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) { function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) {
console.time('count_cost');
countAllByFid(conditions, function(err, count) { countAllByFid(conditions, function(err, count) {
if (err) { if (err) {
console.error(err); console.error(err);
callback(err, null); callback(err, null);
} else { } else {
console.timeEnd('count_cost');
console.time('threads_cost');
var skip = (pageNo - 1) * pageSize; var skip = (pageNo - 1) * pageSize;
var limit = pageSize; var limit = count - skip > pageSize ? pageSize : (count - skip);
var sortBy = '-topTime -tag_topTime -quality -created'; var sortBy = '-topTime -tag_topTime -quality -created';
if (sort) { if (sort) {
sortBy = sort; sortBy = sort;
} }
ForumThread.find(conditions,listThreadFields).populate('from', 'uid mid nickName icon').populate({ ForumThread.find(conditions,listThreadFields).populate('from', 'uid mid nickName icon').populate('info','name icon pv_count').populate({
path: 'tag',select: 'title pv_count'
}).populate({
path: 'comments', path: 'comments',
options: { options: {
where:{status:1}, where:{status:1},
...@@ -750,13 +748,11 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) { ...@@ -750,13 +748,11 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) {
console.error(err); console.error(err);
callback(err, null); callback(err, null);
} else { } else {
console.timeEnd('threads_cost');
var obj = {}; var obj = {};
obj.total = count; obj.total = count;
obj.pageNo = pageNo; obj.pageNo = pageNo;
obj.pageSize = pageSize; obj.pageSize = pageSize;
obj.items = docs; obj.items = docs;
console.time('comments_cost');
if (docs && docs.length > 0) { if (docs && docs.length > 0) {
var asyncTasks = []; var asyncTasks = [];
...@@ -780,7 +776,6 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) { ...@@ -780,7 +776,6 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) {
} else { } else {
obj.items = results; obj.items = results;
callback(null, obj); callback(null, obj);
console.timeEnd('comments_cost');
} }
}); });
......
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