Merged
Conversation
- earn()에 userRepository.save(user) 추가: detached/proxy 엔티티 상태와 무관하게 totalPoints를 DB에 즉시 반영 - checkAndUnlock()에 justEarned 파라미터 추가: REQUIRES_NEW 트랜잭션에서 미커밋 DAILY_LOGIN 로그를 볼 수 없는 문제 해결 - calculateStreak()에서 DAILY_LOGIN 적립 시 오늘 날짜를 직접 포함해 STREAK_7 배지 즉시 unlock
- DAILY_LOGIN 7일 연속 시 STREAK_7 unlock 테스트 추가 - DAILY_LOGIN 연속 일수 부족 시 unlock 안 함 테스트 추가
|
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.



연관 티켓
DP-311
문제
포인트 적립 후
/users/me/points,/users/me/badges조회 시 변경사항이 즉시 반영되지 않는 현상원인 분석
1.
totalPointsDB 미반영PointService.earn()내부에서user.addPoints()호출 후userRepository.save(user)가 없어, 호출자가 detached/proxy 엔티티를 넘긴 경우 JPA dirty checking이 작동하지 않아users.total_points가 DB에 저장되지 않음영향 케이스:
AnswerService.adoptAnswer()→answer.getUser()lazy proxy 전달2.
STREAK_7배지 즉시 unlock 누락checkAndUnlock()은REQUIRES_NEW트랜잭션으로 실행되어 외부 트랜잭션의 미커밋DAILY_LOGINPointLog를 DB에서 조회할 수 없음→ 7일 연속 로그인 직후 STREAK_7 배지가 unlock되지 않고 다음 로그인 시 unlock되는 문제
수정 내용
PointService.javaearn()내userRepository.save(user)추가BadgeService.javacheckAndUnlock(user, justEarned)파라미터 추가,calculateStreak()에서DAILY_LOGIN적립 시 오늘 날짜 직접 포함BadgeServiceTest.javaPointServiceTest.java테스트
BadgeServiceTest전체 통과PointServiceTest전체 통과./gradlew build성공