Skip to content

Commit

Permalink
fix: 댓글 삭제 시 댓글 수가 반영되지 않는 버그 수정
Browse files Browse the repository at this point in the history
* fix: 댓글 삭제 시 개수가 줄어들지 않는 버그 수정

* refactor: 코드 간결하게 수정
  • Loading branch information
jjuny0310 authored Oct 29, 2023
1 parent 117178d commit 59f1809
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<PostImage> images = post.getImages();
if (images.size() >= 1)
Expand Down

0 comments on commit 59f1809

Please sign in to comment.