Commit d23d39fc authored by 陈志良's avatar 陈志良

增加子帖子查询Log

parent babeb4cf
...@@ -579,9 +579,7 @@ router.get('/thread/:tid/get', function(req, res, next) { ...@@ -579,9 +579,7 @@ router.get('/thread/:tid/get', function(req, res, next) {
} }
var threads = []; var threads = [];
threads.push(thread); threads.push(thread);
var firstLoadLevelBegin = new Date();
util.loadLevel(req.session.user.ent_code, threads, function() { util.loadLevel(req.session.user.ent_code, threads, function() {
console.log("获取帖子相关用户的经验(一个OpenId拿一次)总耗时:"+Math.abs(new Date() - firstLoadLevelBegin));
if (threads && threads.length > 0) { if (threads && threads.length > 0) {
thread = threads[0]; thread = threads[0];
} }
...@@ -607,7 +605,6 @@ router.get('/thread/:tid/get', function(req, res, next) { ...@@ -607,7 +605,6 @@ router.get('/thread/:tid/get', function(req, res, next) {
// rs.data = thread; // rs.data = thread;
// res.json(_.assign(rs, returnCode.SUCCESS)); // res.json(_.assign(rs, returnCode.SUCCESS));
} else { } else {
var redisPraiseLogBegin = new Date();
redisPraiseLog.get(ent_code, user.getMobileUser(req), 'thread', function(error, docs) { redisPraiseLog.get(ent_code, user.getMobileUser(req), 'thread', function(error, docs) {
if (thread.toObject) { if (thread.toObject) {
thread = thread.toObject(); thread = thread.toObject();
...@@ -619,7 +616,6 @@ router.get('/thread/:tid/get', function(req, res, next) { ...@@ -619,7 +616,6 @@ router.get('/thread/:tid/get', function(req, res, next) {
break; break;
} }
}; };
console.log("redisPraiseLogTime:"+Math.abs(new Date() - redisPraiseLogBegin));
var rs = {}; var rs = {};
rs.data = thread; rs.data = thread;
res.json(_.assign(rs, returnCode.SUCCESS)); res.json(_.assign(rs, returnCode.SUCCESS));
...@@ -2304,7 +2300,9 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) { ...@@ -2304,7 +2300,9 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
if (tid) { if (tid) {
async.waterfall([ async.waterfall([
function(callback) { function(callback) {
var getByConditionsSelectyFieldBegin = new Date();
forumThreadService.getByConditionsSelectyField({_id:tid}, 'type', function(err, thread) { forumThreadService.getByConditionsSelectyField({_id:tid}, 'type', function(err, thread) {
console.log("获取父帖子耗时:"+ Math.asb(new Date() - getByConditionsSelectyFieldBegin));
if (err) { if (err) {
console.error(err); console.error(err);
callback(err, null); callback(err, null);
...@@ -2314,18 +2312,19 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) { ...@@ -2314,18 +2312,19 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
}); });
}, },
function(thread, callback) { function(thread, callback) {
forumUserThreadControlService.getUserThreadControlById(user.getMobileUser(req), function(err, doc) { callback(null, thread, null);
if (err) { // forumUserThreadControlService.getUserThreadControlById(user.getMobileUser(req), function(err, doc) {
console.error(err); // if (err) {
callback(err, null, null); // console.error(err);
} else { // callback(err, null, null);
if (doc) { // } else {
callback(null, thread, doc); // if (doc) {
} else { // callback(null, thread, doc);
callback(null, thread, null); // } else {
} // callback(null, thread, null);
} // }
}); // }
// });
}, },
function(thread, doc, callback) { function(thread, doc, callback) {
if (thread.type == 2) { //查询子列表 if (thread.type == 2) { //查询子列表
...@@ -2334,8 +2333,10 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) { ...@@ -2334,8 +2333,10 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
$nin: doc.thread $nin: doc.thread
}; };
} }
var getThreadWithNotPopulateCommentBegin = new Date();
//获取子话题数据 //获取子话题数据
forumThreadService.getThreadWithNotPopulateComment(conditions, pageNo, pageSize, sort, function(err, results) { forumThreadService.getThreadWithNotPopulateComment(conditions, pageNo, pageSize, sort, function(err, results) {
console.log("查询子帖子列表耗时:"+Math.asb(new Date() - getThreadWithNotPopulateCommentBegin));
if (err) { if (err) {
console.error(err); console.error(err);
callback(err, null); callback(err, null);
...@@ -2353,8 +2354,12 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) { ...@@ -2353,8 +2354,12 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
res.json(returnCode.BUSY); res.json(returnCode.BUSY);
} else { } else {
if(results){ if(results){
var loadLevelBegin = new Date();
util.loadLevel(ent_code, results.items, function() { util.loadLevel(ent_code, results.items, function() {
console.log("查询用户经验耗时:"+Math.asb(new Date() - loadLevelBegin));
var handleThreadListBegin = new Date();
handleThreadList(req, results, ent_code, function(result){ handleThreadList(req, results, ent_code, function(result){
console.log("查询用户对帖子点赞耗时:"+Math.asb(new Date() - handleThreadListBegin));
res.json(_.assign(result, returnCode.SUCCESS)); res.json(_.assign(result, returnCode.SUCCESS));
}); });
}); });
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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