Skip to content
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

[NAYB-148] feat : 상품에 대한 리뷰 생성 시 Redis에 있는 평균 별점을 갱신한다. #110

Merged
merged 7 commits into from
Sep 16, 2023

Conversation

bjo6300
Copy link
Member

@bjo6300 bjo6300 commented Sep 16, 2023

⛏ 작업 사항

  • 상품에 대한 리뷰 생성 시 평균 별점을 갱신하는 Service, 테스트 코드 구현

📝 작업 요약

  • 상품에 대한 리뷰 생성 시 평균 별점을 갱신하는 Service, 테스트 코드 구현

💡 관련 이슈

NAYB-148

@github-actions
Copy link

github-actions bot commented Sep 16, 2023

Test Results

352 tests  +1   352 ✔️ +1   9s ⏱️ -1s
173 suites ±0       0 💤 ±0 
173 files   ±0       0 ±0 

Results for commit c1b6ed5. ± Comparison against base commit 99c96a9.

This pull request removes 1 and adds 2 tests. Note that renamed tests count towards both.
com.prgrms.nabmart.domain.review.service.RedisCacheServiceTest$GetAverageRateOfReviewsByItem ‑ Redis에 값이 없으면 DB에서 가져오고, 값이 있으면 Redis에서 가져온다.
com.prgrms.nabmart.domain.review.service.RedisCacheServiceTest$GetAverageRatingOfReviewsByItem ‑ Redis에 값이 없으면 DB에서 가져오고, 값이 있으면 Redis에서 가져온다.
com.prgrms.nabmart.domain.review.service.RedisCacheServiceTest$GetAverageRatingOfReviewsByItem ‑ Redis에 값이 있으면 Redis 값을 갱신한다.

♻️ This comment has been updated with latest results.

) {
this.reviewRepository = reviewRepository;
this.numberOfReviewsRedisTemplate = numberOfReviewsRedisTemplate;
this.listOperations = rateRedisTemplate.opsForList();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bean으로 등록한 listOperations와 동일하다면 reidsTemplate을 주입 받지 말고 listOperations를 직접 주입받아도 될 것 같아요! 혹시 동일한 객체인가요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정확해요! 눈썰미 👍🏻

private static final String REVIEW_COUNT_CACHE_KEY = "reviewCount_Item_";
private static final String AVERAGE_RATE_CACHE_KEY = "averageRate_Item_";
private static final String REVIEW_COUNT_CACHE_KEY = "reviewCount:Item:";
private static final String AVERAGE_RATE_CACHE_KEY = "averageRating:Item:";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

키값을 바꾸신 이유는 무엇인가요! 궁금합니다!

Copy link
Member Author

@bjo6300 bjo6300 Sep 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

레디스의 어노테이션을 이용해 변수명이 자동으로 지어질 때 저런 규칙으로 되더라구요! 그래서 변경했습니다 😄

@bjo6300 bjo6300 merged commit bc29383 into develop Sep 16, 2023
3 checks passed
@bjo6300 bjo6300 deleted the feature/NAYB-148 branch September 16, 2023 16:17
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.

2 participants