Skip to content

Conversation

@PicturePark1101
Copy link
Contributor

@PicturePark1101 PicturePark1101 commented Jul 12, 2025

작업내용

조회수 버그 fix 및 로직 변경

상세설명_ & 캡쳐

리워드 지급 안 되었던 이유

  • 이벤트 발행을 after commit으로 설정했는데, Spring 프록시 구조상 RewardService의 트랜잭션이 새로 열리지 않는 문제 발생

[해결]
rewardService에서 트랜잭션 새로 열리도록 옵션 변경

	@Transactional(propagation = Propagation.REQUIRES_NEW)
	public void giveViewCountReward(Member member, Long sharedNoteId, Long 

조회수 로직 변경

  • RDB에서 조회수 읽어오도록 변경했습니다.
  • 어차피 RDB에 접근하기 때문에 조회수 읽는 것에 있어선 캐시의 이점을 사용하지 않는다 판단하여 RDB에서 읽어오고, 조회수 갱신하도록 설정했습니다.
  • 로컬에서 테스트 환료

ViewCountService.java

	public long getViewCount(Member member, SharedNote sharedNote) {
		long sharedNoteId = sharedNote.getSharedNoteId();
		long viewCount = sharedNoteFinder.findViewCountById(sharedNoteId);

		if (!isDuplicate(member.getMemberId(), sharedNoteId) && sharedNote.getDeletedAt() == null) {
			sharedNoteUpdater.updateViewCount(sharedNoteId);
			viewCount++;
			recordViewerHistory(member.getMemberId(), sharedNoteId);

			applicationRewardViewCountPublisherAdapter.checkViewCountRewardPolicy(sharedNote.getMember(),
				sharedNote.getSharedNoteId(), viewCount);
		}
		return viewCount;
	}

@PicturePark1101 PicturePark1101 self-assigned this Jul 12, 2025
@PicturePark1101 PicturePark1101 added ✨ feature 기능 추가 🐞 bugFix 버그 고침 진이 작업했습니다. 👊🏻 PULL REQUEST pr날릴때 labels Jul 12, 2025
@PicturePark1101 PicturePark1101 merged commit e48226f into dev Jul 12, 2025
1 check passed
@PicturePark1101 PicturePark1101 deleted the feat/#434 branch July 12, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

진이 작업했습니다. 🐞 bugFix 버그 고침 ✨ feature 기능 추가 👊🏻 PULL REQUEST pr날릴때

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants