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

좋아요 컬럼 반정규화 #893

Open
wants to merge 6 commits into
base: dev/be
Choose a base branch
from

Conversation

jminkkk
Copy link
Contributor

@jminkkk jminkkk commented Nov 4, 2024

⚡️ 관련 이슈

close #741

📍주요 변경 사항

Template 테이블에 존재하던 좋아요 컬럼을 반정규화하였습니다.

🎸기타

동시성 문제가 발생할 가능성이 높으니 해당 PR 머지 후 문제를 추가 검토하겠습니다.

🍗 PR 첫 리뷰 마감 기한

11/06 13:00

@jminkkk jminkkk added refactor 요구사항이 바뀌지 않은 변경사항 BE 백엔드 labels Nov 4, 2024
@jminkkk jminkkk self-assigned this Nov 4, 2024
Comment on lines 50 to 52
if (FALSE.equals(isLiked(member, template))) {
return;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

기존에는 실제 있는지 확인하지 않고 바로 삭제를 했었는데요~
count--; 를 엔티티 내부에서 해주게 되면서, 확인하는 로직이 없으면 문제가 발생합니다. (내가 좋아요 하지 않은 것도 count-- 되버림)
따라서 검증 추가했어요~!

Copy link
Contributor

@HoeSeong123 HoeSeong123 left a comment

Choose a reason for hiding this comment

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

�코테 끝나자마자 프로젝트를 하다니...
역시 대단하네요 몰리 👍
정말 간단한 코멘트만 2개 남겨놨습니다. 확인 부탁드려요!

@@ -25,11 +28,12 @@ public class LikesService {
@Transactional
public void like(Member member, long templateId) {
Template template = templateRepository.fetchById(templateId);
if (isLiked(member, template)) {
if (TRUE.equals(isLiked(member, template))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

이렇게 변경한 이유가 궁금해요!!

Copy link
Contributor Author

@jminkkk jminkkk Nov 5, 2024

Choose a reason for hiding this comment

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

소나린트가 경고를 띄우더라구요 ㅠㅅㅠ

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

그런데 public Boolean isLiked(Member member, Template template) { // 이 메서드가 래퍼타입 반환하게 되어 있어서네요.
isLiked 메서드가 변경되어야 할 것 같네요

@DisplayName("성공: 여러번 좋아요를 취소해도 정상 동작으로 판단")
void multipleLikes() {
@DisplayName("성공: 본인의 좋아요만 취소 가능")
void multipleCancelLikes() {
Copy link
Contributor

Choose a reason for hiding this comment

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

multiple도 같이 바꿔줘야 할 것 같아요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE 백엔드 refactor 요구사항이 바뀌지 않은 변경사항
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants