Skip to content

[DP-309] 사용자 프로필 recentAnswers 동일 게시글 중복 표시 버그 수정#123

Merged
nYeonG4001 merged 1 commit intodevelopV2from
auto/fix/DP-309-community-profile-duplicate-posts
Apr 12, 2026
Merged

[DP-309] 사용자 프로필 recentAnswers 동일 게시글 중복 표시 버그 수정#123
nYeonG4001 merged 1 commit intodevelopV2from
auto/fix/DP-309-community-profile-duplicate-posts

Conversation

@nYeonG4001
Copy link
Copy Markdown
Collaborator

문제

커뮤니티 사용자 프로필에서 한 게시글에 답변을 여러 개 달면 recentAnswers 배열에 동일 게시글이 답변 수만큼 중복 포함됨.

원인

answerRepository.findByUserIdWithPost()가 답변 1개당 1행을 반환하기 때문에,
같은 게시글에 답변이 3개면 동일 postId를 가진 RecentAnswer 항목이 3개 생성됨.

수정

PublicUserProfileResponse.of()에서 answerspostId 기준으로 중복 제거.
Collectors.toMap + LinkedHashMap으로 순서 보존하며 가장 최신 답변(쿼리 createdAt DESC 기준 첫 번째) 유지.

변경 파일

  • PublicUserProfileResponse.javarecentAnswers 매핑 시 postId 중복 제거
  • UserServiceTest.java — 동일 게시글 다중 답변 중복 제거 검증 테스트 추가

프론트 영향

GET /users/{userId}/profile 응답의 recentAnswers 배열 크기가 줄어들 수 있음.
동일 postId 항목이 중복 제거되어 게시글당 최신 답변 1개만 포함됨.
별도 UI 수정은 불필요하나, 프론트에서 중복 필터링 로직이 있었다면 제거 가능.

테스트

  • UserServiceTest 전체 통과
  • ./gradlew build 통과

한 게시글에 답변을 여러 개 달았을 때 recentAnswers에 동일 postId가
답변 수만큼 중복 포함되던 버그 수정. Collectors.toMap으로 postId 기준
중복 제거 (가장 최신 답변 유지). 중복 제거 검증 테스트 추가.
@sonarqubecloud
Copy link
Copy Markdown

@nYeonG4001 nYeonG4001 merged commit bc07e04 into developV2 Apr 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant