Skip to content

Commit

Permalink
fix: comments count API 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
mangowhoiscloud committed Nov 6, 2024
1 parent f286a91 commit fb6b3c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public class ParentComment extends BaseEntity {
@OneToMany(mappedBy = "parentComment", fetch = FetchType.LAZY)
private List<ParentCommentLike> parentCommentLikes;

public Integer getCommentsCount() {
return childComments.size() + 1;
public Integer getChildCommentsCount() {
return childComments.size();
}

public Integer getLikesCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ public Integer getPostViewsCount() {
}

public Integer getCommentsCount() {
return parentComments
.stream()
.map(ParentComment::getCommentsCount)
.reduce(1, Integer::sum);
return parentComments.size() +
parentComments.stream()
.map(ParentComment::getChildCommentsCount)
.reduce(0, Integer::sum);
}

public void delete() {
Expand Down

0 comments on commit fb6b3c4

Please sign in to comment.