-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
밸런스 게임 조회수가 증가하지 않는 이슈 #863
Conversation
Walkthrough
Changes
Assessment against linked issues
Poem
Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/main/java/balancetalk/game/application/GameService.java (1)
154-156
: @transactional 수정이 적절합니다.readOnly=true 제거는 조회수 증가 기능을 정상적으로 동작하게 만드는 올바른 해결책입니다.
하지만 성능 최적화를 위해 읽기/쓰기 작업을 분리하는 것을 고려해보시기 바랍니다.
다음과 같이 리팩토링하는 것을 제안드립니다:
- @Transactional - public GameSetDetailResponse findBalanceGameSet(final Long gameSetId, final GuestOrApiMember guestOrApiMember) { - GameSet gameSet = gameSetRepository.findById(gameSetId) - .orElseThrow(() -> new BalanceTalkException(ErrorCode.NOT_FOUND_BALANCE_GAME_SET)); - gameSet.increaseViews(); + @Transactional + public void increaseGameSetViews(final Long gameSetId) { + GameSet gameSet = gameSetRepository.findById(gameSetId) + .orElseThrow(() -> new BalanceTalkException(ErrorCode.NOT_FOUND_BALANCE_GAME_SET)); + gameSet.increaseViews(); + } + + @Transactional(readOnly = true) + public GameSetDetailResponse findBalanceGameSet(final Long gameSetId, final GuestOrApiMember guestOrApiMember) { + increaseGameSetViews(gameSetId); + GameSet gameSet = gameSetRepository.findById(gameSetId) + .orElseThrow(() -> new BalanceTalkException(ErrorCode.NOT_FOUND_BALANCE_GAME_SET));이렇게 분리하면 다음과 같은 이점이 있습니다:
- 조회 로직에 readOnly=true 최적화를 적용할 수 있습니다
- 단일 책임 원칙(SRP)을 더 잘 준수합니다
- 조회수 증가 로직을 다른 곳에서도 재사용할 수 있습니다
Quality Gate passedIssues Measures |
💡 작업 내용
@Transactional(readOnly = true)
에서 readOnly 옵션 제거💡 자세한 설명
기존에
readOnly = true
라는 조건을 붙이면서 게임을 조회할 때 update 쿼리가 실행되지 않았습니다.따라서, views 필드가 조회를 해도 업데이트 되지 않고 그대로 0으로 남아있는 오류가 발생했습니다.
@Transactional
로 변경함에 따라 성공적으로 업데이트 쿼리가 나가는 것을 확인했습니다.📗 참고 자료 (선택)
📢 리뷰 요구 사항 (선택)
🚩 후속 작업 (선택)
✅ 셀프 체크리스트
closes #862
Summary by CodeRabbit