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
9b7830a2
Commit
9b7830a2
authored
Mar 16, 2016
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
6404a060
' into SANDBOX
parents
e6ad37f7
6404a060
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
30 deletions
+23
-30
forumThreadService.js
app/service/forumThreadService.js
+23
-30
No files found.
app/service/forumThreadService.js
View file @
9b7830a2
...
@@ -770,42 +770,35 @@ function getSubThreads(doc, sort, callback) {
...
@@ -770,42 +770,35 @@ function getSubThreads(doc, sort, callback) {
pid
:
doc
.
_id
,
pid
:
doc
.
_id
,
status
:
1
status
:
1
};
};
countAllByFid
(
conditions
,
function
(
err
,
count
)
{
var
sortBy
=
'-top -quality -created'
;
if
(
sort
)
{
sortBy
=
sort
;
}
ForumThread
.
find
(
conditions
,
subThreadFields
).
populate
(
'from'
,
'icon'
).
sort
(
sortBy
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
callback
(
err
,
null
);
}
else
{
}
else
{
var
sortBy
=
'-top -quality -created'
;
var
list
=
[];
//用户去重
if
(
sort
)
{
_
.
forEach
(
docs
,
function
(
one
,
i
)
{
sortBy
=
sort
;
var
flag
=
true
;
}
_
.
forEach
(
list
,
function
(
two
,
k
)
{
ForumThread
.
find
(
conditions
,
subThreadFields
).
populate
(
'from'
,
'icon'
).
sort
(
sortBy
).
exec
(
function
(
err
,
docs
)
{
if
(
one
.
from
.
_id
==
two
.
from
.
_id
){
if
(
err
)
{
flag
=
false
;
console
.
error
(
err
);
}
callback
(
err
,
null
);
});
}
else
{
if
(
flag
){
var
list
=
[];
//用户去重
list
.
push
(
one
);
_
.
forEach
(
docs
,
function
(
one
,
i
)
{
var
flag
=
true
;
_
.
forEach
(
list
,
function
(
two
,
k
)
{
if
(
one
.
from
.
_id
==
two
.
from
.
_id
){
flag
=
false
;
}
});
if
(
flag
){
list
.
push
(
one
);
}
});
var
obj
=
{};
obj
.
total
=
count
;
obj
.
items
=
list
;
var
newDoc
=
doc
.
toObject
();
newDoc
.
subThreads
=
obj
;
callback
(
null
,
newDoc
);
}
}
});
});
var
obj
=
{};
obj
.
total
=
list
.
length
;
obj
.
items
=
list
;
var
newDoc
=
doc
.
toObject
();
newDoc
.
subThreads
=
obj
;
callback
(
null
,
newDoc
);
}
}
});
});
}
}
...
...
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