-
Notifications
You must be signed in to change notification settings - Fork 5
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
[Feature] - 여행기 정렬 및 날짜별 필터링 추가 #442
Conversation
Test Results 31 files 31 suites 8s ⏱️ Results for commit 531a7b7. ♻️ This comment has been updated with latest results. |
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.
고생하셨습니다 클로버!
몇가지 코멘트 남겼는데 확인해주세요!
if (filter.isNoCondition()) { | ||
return ResponseEntity.ok(travelogueFacadeService.findSimpleTravelogues(pageable)); | ||
} | ||
return ResponseEntity.ok(travelogueFacadeService.findSimpleTravelogues(filter, pageable)); |
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.
저도 동의합니다!! 필터 조건이 있냐 없냐에 따라 다른 동작을 한다는 것을 컨트롤러가 모르는 것이 더 좋을 것 같아요!!
@@ -49,19 +51,24 @@ public class Travelogue extends BaseEntity { | |||
@Column(nullable = false) | |||
private String thumbnail; | |||
|
|||
@Column(nullable = false) | |||
@ColumnDefault("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.
와우 이런 어노테이션이 있군요..
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.
DB 스키마에 디폴트 값을 설정하는 애너테이션이군요옵.
저희 빈 값으로 Insert가 나가지는 않을 것 같은데 필요할까요?
클로버의 의도가 궁금합니다리 🤔
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.
기존 데이터와 호환을 위해 default 값 설정해줬습니다.
근데 사실 기존 데이터가 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.
고생 많았슴다 응로버씌!!
dto 패키지 의존성 관련해서는 구두로 이야기 나누어서 따로 리뷰 남기지는 않았습니다!
리뷰 확인 되면 approve 드릴게요!!
if (filter.isNoCondition()) { | ||
return ResponseEntity.ok(travelogueFacadeService.findSimpleTravelogues(pageable)); | ||
} | ||
return ResponseEntity.ok(travelogueFacadeService.findSimpleTravelogues(filter, pageable)); |
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.
저도 동의합니다!! 필터 조건이 있냐 없냐에 따라 다른 동작을 한다는 것을 컨트롤러가 모르는 것이 더 좋을 것 같아요!!
public void increaseLikeCount() { | ||
likeCount += LIKE_COUNT_WEIGHT; | ||
} | ||
|
||
public void decreaseLikeCount() { | ||
likeCount -= LIKE_COUNT_WEIGHT; | ||
} |
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.
변경 감지를 이용하게 되면서, 서로 다른 트랜잭션에서 race condition 이 발생할 수 있겠네요!
저희 모두 인지는 하고 있으나, 현재 데모데이 요구사항을 지키는 것이 더 우선순위가 높은 것 같아 다음 스프린트 때 해결해 보도록 하시죠!!
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.
인지해두겠습니다 👍
return; | ||
} | ||
|
||
if (filter.period() == 8) { |
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.
클로버 수고하셨습니다 🍀
우선 제 생각에는 코드의 가독성을 조금 더 챙겨볼 수 있을 것 같아 RC 드립니다.
제 생각이 틀릴 수도 있어서 클로버와 의견 나눠보고 싶네요~
@@ -49,19 +51,24 @@ public class Travelogue extends BaseEntity { | |||
@Column(nullable = false) | |||
private String thumbnail; | |||
|
|||
@Column(nullable = false) | |||
@ColumnDefault("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.
DB 스키마에 디폴트 값을 설정하는 애너테이션이군요옵.
저희 빈 값으로 Insert가 나가지는 않을 것 같은데 필요할까요?
클로버의 의도가 궁금합니다리 🤔
public void increaseLikeCount() { | ||
likeCount += LIKE_COUNT_WEIGHT; | ||
} | ||
|
||
public void decreaseLikeCount() { | ||
likeCount -= LIKE_COUNT_WEIGHT; | ||
} |
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.
개인적으로는 +1이 좀 더 가독성 있다고 생각하는데 어떻게 생각하시나유?
지금 구현도 크게 위화감 있다고 생각하지 않아서요~ 반드시 변경하기보다 클로버가 마음가는 구현으로 남겨주세요!
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.
1이 가독성 있긴한데 매직넘버라 생각해 분리해뒀습니다.하나로 관리하는게 증가, 삭제 일관성 지키기도 더 쉬울 것 같구요.
일단 유지하겠습니다!
import kr.touroot.travelogue.domain.Travelogue; | ||
import kr.touroot.travelogue.dto.request.TravelogueFilterCondition; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
public interface TravelogueQueryRepository { | ||
|
||
Page<Travelogue> findByTitleContaining(String keyword, Pageable pageable); | ||
|
||
Page<Travelogue> findAllByTag(List<Long> tagFilter, Pageable pageable); | ||
Page<Travelogue> findAllByFilter(TravelogueFilterCondition filter, Pageable pageable); | ||
} |
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.
리건에게 드렸던 코멘트랑 비슷한데요..!
dto의 침투 막아주는 것이 좋을 것 같습니다.
당장은 의미없는 매핑일 수 있어도 진행해놓으면 api 명세 수정에 잘 견딜 수 있다고 생각해요!
public Page<Travelogue> findAllByFilter(TravelogueFilterCondition filter, Pageable pageable) { | ||
JPAQuery<Travelogue> query = jpaQueryFactory.select(travelogue) | ||
.from(travelogueTag); | ||
|
||
addTagFilter(query, filter); | ||
addPeriodFilter(query, filter); | ||
|
||
List<Travelogue> results = query.orderBy(findSortCondition(pageable.getSort())) |
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.
findAllByFilter 메서드 속에 findSortCondition이 있네요!
find로 시작하는 메서드는 레포지토리 조회 수준의 기능을 제공할 것 같은데 OrderSpecifier를 제공하고 있어요.
findSortCondition의 네이밍을 다음 중 하나, 혹은 클로버가 생각하는 다른 이름으로 바꿔보는 것은 어떨까요??
- getSortConditionFrom(pageable)
- getOrderSpecifier(pageable)
if (filter.period() == 8) { | ||
query.where(travelogueTag.travelogue.travelogueDays.size().goe(8)); | ||
return; | ||
} |
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.
8은 필터링 최대 기간이라는 의미를 가진 상수인 듯 해요..!
상수 추출을 부탁드리려고 했는데.. 조금 더 생각해보니 다른 생각도 드네요 🤔
서비스 속으로 명세가 숨어야 하는 부분이 아닐까요?
클로버의 의견도 공유해주세요~
query.where(travelogueTag.tag.id.in(filter.tag())) | ||
.groupBy(travelogueTag.travelogue) | ||
.having(isSameCountWithFilter(filter.tag())); |
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.
isSameCountWithFilter(filter.tag())
위 메서드는 필터 개수를 인자로 받는 것이 (Integer를 파라미터로 받는 것) 훨씬 자연스러운 것 같아요.
filterCount 등으로 메서드 명이 가독성 있게 바뀔 수 있고 메서드내에서 불필요한 접근 연산자 (.)도 제거할 수 있겠군요.
++ filter.tag()를 변수로 추출해서 사용하는 것이 좋아보여요. 여러번 사용되기도 하고 개수등을 뽑아서 넘길 때도 훨씬 편해질 수 있을 것 같습니다
사실
public Page<Travelogue> findAllByFilter(List<Long> filter, Pageable pageable) { | ||
return travelogueQueryRepository.findAllByTag(filter, pageable); | ||
public Page<Travelogue> findAllByFilter(TravelogueFilterCondition filter, Pageable pageable) { | ||
return travelogueQueryRepository.findAllByFilter(filter, pageable); |
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.
뒤늦게 수정이 들어가서 outdated 된 애들은 일단 답변 달지 않았습니다. (거의 반영된 것 같네요.)
다시 한 번 확인해주시면 감사하겠습니다.
@@ -49,19 +51,24 @@ public class Travelogue extends BaseEntity { | |||
@Column(nullable = false) | |||
private String thumbnail; | |||
|
|||
@Column(nullable = false) | |||
@ColumnDefault("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.
기존 데이터와 호환을 위해 default 값 설정해줬습니다.
근데 사실 기존 데이터가 0으로 전부 밀어져도 되나 싶긴 하네요.
삭제하는게 좋을지 의견 한 번 주시면 감사하겠습니다.
public void increaseLikeCount() { | ||
likeCount += LIKE_COUNT_WEIGHT; | ||
} | ||
|
||
public void decreaseLikeCount() { | ||
likeCount -= LIKE_COUNT_WEIGHT; | ||
} |
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.
인지해두겠습니다 👍
public void increaseLikeCount() { | ||
likeCount += LIKE_COUNT_WEIGHT; | ||
} | ||
|
||
public void decreaseLikeCount() { | ||
likeCount -= LIKE_COUNT_WEIGHT; | ||
} |
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.
1이 가독성 있긴한데 매직넘버라 생각해 분리해뒀습니다.하나로 관리하는게 증가, 삭제 일관성 지키기도 더 쉬울 것 같구요.
일단 유지하겠습니다!
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.
DefaultColumn만 수정해주세요~
고생하셨습니다 로버로버클로버
if (filter.isEmptyTagCondition()) { | ||
return; | ||
} | ||
|
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.
오호라 고순가?
private Page<Travelogue> findSimpleTraveloguesByFilter(TravelogueFilterCondition filter, Pageable pageable) { | ||
if (filter.isEmptyCondition()) { | ||
return travelogueService.findAll(pageable); | ||
} | ||
|
||
return travelogueService.findAllByFilter(filter, pageable); |
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.
저도 리뷰 반영된 것 잘 확인했습니다!!
approve 드립니닷
flyway script 까먹지 마시죠! |
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.
LGTM GGWP 👍
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.
LGTM GGWP 👍
✅ 작업 내용
참고사항
@GetMapping(params=)
를 활용한 오버라이딩은 두 개 모두 존재할 때 사용할 수 있습니다. 따라서 컨트롤러에 if 분기 로직이 들어갔는데요, 분기로직을 서비스로 빼는게 나을지 의견 부탁드립니다.