[DP-309] 사용자 프로필 recentAnswers 동일 게시글 중복 표시 버그 수정#123
Merged
nYeonG4001 merged 1 commit intodevelopV2from Apr 12, 2026
Merged
Conversation
한 게시글에 답변을 여러 개 달았을 때 recentAnswers에 동일 postId가 답변 수만큼 중복 포함되던 버그 수정. Collectors.toMap으로 postId 기준 중복 제거 (가장 최신 답변 유지). 중복 제거 검증 테스트 추가.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



문제
커뮤니티 사용자 프로필에서 한 게시글에 답변을 여러 개 달면
recentAnswers배열에 동일 게시글이 답변 수만큼 중복 포함됨.원인
answerRepository.findByUserIdWithPost()가 답변 1개당 1행을 반환하기 때문에,같은 게시글에 답변이 3개면 동일
postId를 가진RecentAnswer항목이 3개 생성됨.수정
PublicUserProfileResponse.of()에서answers를postId기준으로 중복 제거.Collectors.toMap+LinkedHashMap으로 순서 보존하며 가장 최신 답변(쿼리createdAt DESC기준 첫 번째) 유지.변경 파일
PublicUserProfileResponse.java—recentAnswers매핑 시 postId 중복 제거UserServiceTest.java— 동일 게시글 다중 답변 중복 제거 검증 테스트 추가프론트 영향
GET /users/{userId}/profile응답의recentAnswers배열 크기가 줄어들 수 있음.동일
postId항목이 중복 제거되어 게시글당 최신 답변 1개만 포함됨.별도 UI 수정은 불필요하나, 프론트에서 중복 필터링 로직이 있었다면 제거 가능.
테스트
UserServiceTest전체 통과./gradlew build통과