diff --git a/src/main/java/com/ssafy/ssafsound/domain/post/dto/GetPostElement.java b/src/main/java/com/ssafy/ssafsound/domain/post/dto/GetPostElement.java index 42debfac..53ad0f1f 100644 --- a/src/main/java/com/ssafy/ssafsound/domain/post/dto/GetPostElement.java +++ b/src/main/java/com/ssafy/ssafsound/domain/post/dto/GetPostElement.java @@ -38,13 +38,18 @@ public GetPostElement(Post post) { this.title = post.getTitle(); this.content = post.getContent(); this.likeCount = post.getLikes().size(); - this.commentCount = post.getComments().size(); + this.commentCount = getCommentSize(post); this.createdAt = post.getCreatedAt(); this.nickname = anonymity ? "익명" : post.getMember().getNickname(); this.anonymity = anonymity; this.thumbnail = findThumbnailUrl(post); } + private int getCommentSize(Post post) { + return (int) post.getComments().stream() + .filter(comment -> !comment.getDeletedComment()).count(); + } + private String findThumbnailUrl(Post post) { List images = post.getImages(); if (images.size() >= 1)