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
2678facf
Commit
2678facf
authored
Dec 08, 2015
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'remould_1120_spreadchain' into SANDBOX
parents
5b13b98c
52fe4c82
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
0 deletions
+96
-0
forumThread.js
app/controllers/admin/forumThread.js
+96
-0
No files found.
app/controllers/admin/forumThread.js
View file @
2678facf
...
@@ -1078,6 +1078,102 @@ router.get('/thread/:tid/spreadchain', function(req, res, next) {
...
@@ -1078,6 +1078,102 @@ router.get('/thread/:tid/spreadchain', function(req, res, next) {
});
});
//udpate by Car 20151208 使用redis优化传播链图
router
.
get
(
'/thread/:tid/spreadchainByRedis'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
,
ent_code
=
req
.
session
.
user
.
ent_code
;
var
openIds
=
[];
then
.
parallel
([
function
(
cont
)
{
ForumThread
.
findOne
({
_id
:
tid
,
ent_code
:
ent_code
}).
populate
(
'from'
).
exec
(
function
(
err
,
doc
)
{
cont
(
err
,
doc
);
});
},
function
(
cont
)
{
ForumPVLog
.
find
({
thread
:
tid
,
ent_code
:
ent_code
}).
sort
(
'source created'
).
populate
(
'user source'
).
exec
(
function
(
err
,
docs
)
{
cont
(
err
,
docs
);
});
}
]).
then
(
function
(
cont
,
results
)
{
var
thread
=
results
[
0
],
pvs
=
results
[
1
];
var
data
=
{
openId
:
thread
.
from
.
uid
,
name
:
thread
.
from
.
nickName
,
//nickName: thread.from.displayName,
nickName
:
thread
.
from
.
nickName
,
children
:
[]
,
id
:
'ROOT'
}
//获取一级传播
for
(
var
i
=
0
;
i
<
pvs
.
length
;
i
+=
1
)
{
var
pv
=
pvs
[
i
];
if
(
!
pv
.
source
)
{
var
flag
=
false
;
for
(
var
j
=
0
;
j
<
data
.
children
.
length
;
j
+=
1
)
{
var
c
=
data
.
children
[
j
];
if
(
c
.
openId
===
pv
.
open_id
)
{
flag
=
true
;
break
;
}
}
if
(
!
flag
&&
pv
.
open_id
!==
data
.
openId
&&
!
checkOpenIds
(
openIds
,
pv
.
open_id
))
{
data
.
children
.
push
({
openId
:
pv
.
open_id
,
nickName
:
pv
.
user
.
displayName
||
'未知'
,
name
:
pv
.
user
.
nickName
||
'未知'
,
id
:
pv
.
_id
});
openIds
.
push
(
pv
.
open_id
);
}
}
}
//获取非一级传播
var
new_pvs
=
[];
for
(
var
i
=
0
;
i
<
pvs
.
length
;
i
+=
1
)
{
if
(
pvs
[
i
].
source
&&
pvs
[
i
].
source
.
uid
!==
data
.
openId
&&
pvs
[
i
].
open_id
!==
data
.
openId
)
{
new_pvs
.
push
(
pvs
[
i
]);
}
}
pvs
=
new_pvs
;
//递归其他传播
var
thenTask
=
[];
_
.
forEach
(
data
.
children
,
function
(
c
)
{
thenTask
.
push
(
function
(
cb
)
{
getSubSpreadPaths
(
openIds
,
c
,
pvs
,
cb
);
});
})
then
.
parallel
(
thenTask
).
then
(
function
(
cont
,
childrens
)
{
data
.
children
=
childrens
;
//put data into redis
var
key
=
tid
+
"_spreadchain"
console
.
log
(
"spreadchain data="
+
data
);
redis
.
set
(
key
,
JSON
.
stringify
(
data
));
redis
.
expire
(
key
,
60
);
var
rs
=
{
data
:
key
}
openIds
=
[];
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
});
}).
fail
(
function
(
cont
,
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
});
});
// 导出文章评论内容
// 导出文章评论内容
router
.
get
(
'/thread/:tid/exportComments'
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'/thread/:tid/exportComments'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
,
var
tid
=
req
.
params
.
tid
||
null
,
...
...
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