mirror of https://github.com/halo-dev/halo
fix: incorrect number of children comment. (#1332)
parent
f9a629c38f
commit
602f1704a1
|
@ -223,4 +223,22 @@ public interface BaseCommentRepository<COMMENT extends BaseComment>
|
|||
@NonNull
|
||||
List<CommentChildrenCountProjection> findDirectChildrenCount(
|
||||
@NonNull Collection<Long> commentIds);
|
||||
|
||||
/**
|
||||
* Finds direct children count by comment ids and status.
|
||||
*
|
||||
* @param commentIds comment ids must not be null.
|
||||
* @param status comment status must not be null.
|
||||
* @return a list of CommentChildrenCountProjection
|
||||
*/
|
||||
@Query(
|
||||
"select new run.halo.app.model.projection.CommentChildrenCountProjection(count(comment"
|
||||
+ ".id), comment.parentId) "
|
||||
+ "from BaseComment comment "
|
||||
+ "where comment.parentId in ?1 "
|
||||
+ "and comment.status = ?2 "
|
||||
+ "group by comment.parentId")
|
||||
@NonNull
|
||||
List<CommentChildrenCountProjection> findDirectChildrenCount(
|
||||
@NonNull Collection<Long> commentIds, @NonNull CommentStatus status);
|
||||
}
|
||||
|
|
|
@ -580,7 +580,7 @@ public abstract class BaseCommentServiceImpl<COMMENT extends BaseComment>
|
|||
|
||||
// Get direct children count
|
||||
List<CommentChildrenCountProjection> directChildrenCount =
|
||||
baseCommentRepository.findDirectChildrenCount(topCommentIds);
|
||||
baseCommentRepository.findDirectChildrenCount(topCommentIds, CommentStatus.PUBLISHED);
|
||||
|
||||
// Convert to comment - children count map
|
||||
Map<Long, Long> commentChildrenCountMap = ServiceUtils
|
||||
|
|
Loading…
Reference in New Issue