Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pisns-forum-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
scrmGroup
pisns-forum-api
Commits
d23d39fc
Commit
d23d39fc
authored
Jul 28, 2016
by
陈志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加子帖子查询Log
parent
babeb4cf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1746 additions
and
1746 deletions
+1746
-1746
forumThread.js
app/controllers/mobile/forumThread.js
+21
-16
forumThreadService.js
app/service/forumThreadService.js
+1725
-1730
No files found.
app/controllers/mobile/forumThread.js
View file @
d23d39fc
...
...
@@ -579,9 +579,7 @@ router.get('/thread/:tid/get', function(req, res, next) {
}
var
threads
=
[];
threads
.
push
(
thread
);
var
firstLoadLevelBegin
=
new
Date
();
util
.
loadLevel
(
req
.
session
.
user
.
ent_code
,
threads
,
function
()
{
console
.
log
(
"获取帖子相关用户的经验(一个OpenId拿一次)总耗时:"
+
Math
.
abs
(
new
Date
()
-
firstLoadLevelBegin
));
if
(
threads
&&
threads
.
length
>
0
)
{
thread
=
threads
[
0
];
}
...
...
@@ -607,7 +605,6 @@ router.get('/thread/:tid/get', function(req, res, next) {
// rs.data = thread;
// res.json(_.assign(rs, returnCode.SUCCESS));
}
else
{
var
redisPraiseLogBegin
=
new
Date
();
redisPraiseLog
.
get
(
ent_code
,
user
.
getMobileUser
(
req
),
'thread'
,
function
(
error
,
docs
)
{
if
(
thread
.
toObject
)
{
thread
=
thread
.
toObject
();
...
...
@@ -619,7 +616,6 @@ router.get('/thread/:tid/get', function(req, res, next) {
break
;
}
};
console
.
log
(
"redisPraiseLogTime:"
+
Math
.
abs
(
new
Date
()
-
redisPraiseLogBegin
));
var
rs
=
{};
rs
.
data
=
thread
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
...
...
@@ -2304,7 +2300,9 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
if
(
tid
)
{
async
.
waterfall
([
function
(
callback
)
{
var
getByConditionsSelectyFieldBegin
=
new
Date
();
forumThreadService
.
getByConditionsSelectyField
({
_id
:
tid
},
'type'
,
function
(
err
,
thread
)
{
console
.
log
(
"获取父帖子耗时:"
+
Math
.
asb
(
new
Date
()
-
getByConditionsSelectyFieldBegin
));
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
@@ -2314,18 +2312,19 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
});
},
function
(
thread
,
callback
)
{
forumUserThreadControlService
.
getUserThreadControlById
(
user
.
getMobileUser
(
req
),
function
(
err
,
doc
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
,
null
);
}
else
{
if
(
doc
)
{
callback
(
null
,
thread
,
doc
);
}
else
{
callback
(
null
,
thread
,
null
);
}
}
});
// forumUserThreadControlService.getUserThreadControlById(user.getMobileUser(req), function(err, doc) {
// if (err) {
// console.error(err);
// callback(err, null, null);
// } else {
// if (doc) {
// callback(null, thread, doc);
// } else {
// callback(null, thread, null);
// }
// }
// });
},
function
(
thread
,
doc
,
callback
)
{
if
(
thread
.
type
==
2
)
{
//查询子列表
...
...
@@ -2334,8 +2333,10 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
$nin
:
doc
.
thread
};
}
var
getThreadWithNotPopulateCommentBegin
=
new
Date
();
//获取子话题数据
forumThreadService
.
getThreadWithNotPopulateComment
(
conditions
,
pageNo
,
pageSize
,
sort
,
function
(
err
,
results
)
{
console
.
log
(
"查询子帖子列表耗时:"
+
Math
.
asb
(
new
Date
()
-
getThreadWithNotPopulateCommentBegin
));
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
@@ -2353,8 +2354,12 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
results
){
var
loadLevelBegin
=
new
Date
();
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
){
console
.
log
(
"查询用户对帖子点赞耗时:"
+
Math
.
asb
(
new
Date
()
-
handleThreadListBegin
));
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
});
});
...
...
app/service/forumThreadService.js
View file @
d23d39fc
...
...
@@ -299,7 +299,6 @@ exports.getByConditions = function(conditions, callback) {
}
//根据ID获取文章
exports
.
getThreadById
=
function
(
tid
,
callback
)
{
var
begin
=
new
Date
().
getTime
();
ForumThread
.
findOne
({
_id
:
tid
}).
populate
({
path
:
'from'
,
select
:
'uid mid nickName icon exp honorTitles'
...
...
@@ -322,7 +321,6 @@ exports.getThreadById = function(tid, callback) {
};
//获取最新10条评论
forumCommentService
.
getAllComment
(
conditions
,
1
,
10
,
function
(
err
,
results
)
{
console
.
log
(
"获取最新10条评论耗时:"
+
Math
.
abs
(
new
Date
()
-
getAllCommentBegin
));
if
(
err
)
{
console
.
log
(
err
);
cb
(
err
,
null
);
...
...
@@ -406,7 +404,6 @@ exports.getThreadById = function(tid, callback) {
// });
// },
function
(
cb
)
{
var
canyuPeopleCountBegin
=
new
Date
();
//获取发帖人数
var
key
=
'pisns-forum-thread:'
+
tid
+
':amount'
;
redis
.
get
(
key
,
function
(
err
,
value
){
...
...
@@ -436,7 +433,6 @@ exports.getThreadById = function(tid, callback) {
}
});
}
console
.
log
(
"获取发帖人数耗时:"
+
Math
.
abs
(
new
Date
()
-
begin
));
});
// ForumThread.aggregate({
...
...
@@ -477,7 +473,6 @@ exports.getThreadById = function(tid, callback) {
// threadObj.latestPhotos = latestPhotos;
// threadObj.hotPhotos = hotPhotos;
threadObj
.
canyuPeopleCount
=
canyuPeopleCount
;
console
.
log
(
"获取帖子内容总耗时:"
+
Math
.
abs
(
new
Date
()
-
begin
));
callback
(
null
,
threadObj
);
}
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment