-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: 식당 조회시 북마크 수량 조회 기능 #204
Conversation
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.
테스트까지 잘 구현해주셨네요 백호!
소소한 리뷰 남겼으니 확인부탁드려요:)
matzip-app-external-api/src/main/java/com/woowacourse/matzip/application/RestaurantService.java
Outdated
Show resolved
Hide resolved
matzip-app-external-api/src/main/java/com/woowacourse/matzip/application/RestaurantService.java
Show resolved
Hide resolved
...app-external-api/src/test/java/com/woowacourse/matzip/application/RestaurantServiceTest.java
Outdated
Show resolved
Hide resolved
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.
수고하셨어요~
for (int i = 1; i <= 3; i++) { | ||
Member member = createTestMember("githubId" + i); | ||
memberRepository.save(member); | ||
|
||
bookmarkRepository.save(createTestBookmark(member, restaurant)); | ||
} |
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.
for (int i = 1; i <= 3; i++) { | |
Member member = createTestMember("githubId" + i); | |
memberRepository.save(member); | |
bookmarkRepository.save(createTestBookmark(member, restaurant)); | |
} | |
Member member1 = memberRepository.save(createTestMember("githubId1")); | |
bookmarkRepository.save(createTestBookmark(member1, restaurant)); | |
Member member2 = memberRepository.save(createTestMember("githubId2")); | |
bookmarkRepository.save(createTestBookmark(member2, restaurant)); | |
Member member3 = memberRepository.save(createTestMember("githubId3")); | |
bookmarkRepository.save(createTestBookmark(member3, restaurant)); |
가능하면 테스트에는 for와 같은 로직보다는 차라리 하드코딩해서 각 값을 넣어주는 것이 좋을 것 같아요.
물론 로직이 단순할 수도 있지만 1~3이라는 로직자체가들어갔다는 것은 그 구문을 이해해야하는 범위가 늘어나 직관적이지 못하고 간단하더라도 오류를 범할 수 있기 때문이에요.
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.
호오 확실히 직관적으로 보이네요!
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.
3개 정도는 하드코딩으로 넣는 것이 훨씬 직관적으로 보이네요!
@@ -79,7 +80,8 @@ public RestaurantResponse findById(final String githubId, final Long restaurantI | |||
.orElseThrow(RestaurantNotFoundException::new), | |||
reviewRepository.findAverageRatingUsingRestaurantId(restaurantId) | |||
.orElse(0.0), | |||
isBookmarked(githubId, restaurantId)); | |||
isBookmarked(githubId, restaurantId), | |||
bookmarkRepository.countByRestaurantId(restaurantId)); |
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.
bookmarkRepository.countByRestaurantId(restaurantId)); | |
bookmarkRepository.countByRestaurantId(restaurantId) | |
); |
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.
수고하셨습니다 백호 ~! 😃
간단한 의견 남겨봤으니 확인해주시면 감사하겠습니다 😊
matzip-app-external-api/src/main/java/com/woowacourse/matzip/application/RestaurantService.java
Outdated
Show resolved
Hide resolved
@@ -79,7 +80,8 @@ public RestaurantResponse findById(final String githubId, final Long restaurantI | |||
.orElseThrow(RestaurantNotFoundException::new), | |||
reviewRepository.findAverageRatingUsingRestaurantId(restaurantId) | |||
.orElse(0.0), |
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.
기존에 작성되어 있는 코드 같은데
0.0이라는 값이 직관적으로 다가오지 않다고 느껴져
이를 DEFAULT_RATING 같이 상수로 관리하는 건 어떻게 생각하시나요 ?
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.
기본 별점이 0.0에서 바뀌는 경우가 없을 것 같고 바로 0.0점을 확인하는 것이 더 직관적일 것 같습니다.
상수로 관리하게 되면 기본값이 0.0이 아닐 수 있나?
라는 생각에 코드 상단으로 다시 올라가야하는 불편함이 있을 것 같습니다.
...ternal-api/src/main/java/com/woowacourse/matzip/application/response/RestaurantResponse.java
Show resolved
Hide resolved
|
issue: #203
as-is
to-be