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

[feat] 감상 전체 조회 기능 추가 (#363) #367

Merged
merged 20 commits into from
Sep 19, 2023

Conversation

Jaeyoung22
Copy link
Collaborator

📌 관련 이슈

📁 작업 설명

  • 조건별로 감상을 전체 조회하는 기능을 구현했습니다.

💻 미완료 태스크(선택)

  • 인덱스를 위한 DB Schema 변경
  • 가입 시 연령대와 성별 받아오기
  • 해가 지나면 나이 업데이트 어떻게 할지

@Jaeyoung22 Jaeyoung22 self-assigned this Sep 17, 2023
@Jaeyoung22 Jaeyoung22 changed the title Feature/#363 [feat] 감상 전체 조회 기능 추가 (#363) Sep 17, 2023
@github-actions
Copy link

github-actions bot commented Sep 17, 2023

Test Results

200 tests   200 ✔️  14s ⏱️
  51 suites      0 💤
  51 files        0

Results for commit 2168d1d.

♻️ This comment has been updated with latest results.

Copy link
Member

@greeng00se greeng00se left a comment

Choose a reason for hiding this comment

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

새로운 기술을 빨리 학습하고 기능 추가를 해주신 부분 정말 대단한 것 같습니다.
기능 구현에 있어서는 군더더기 없이 깔끔하게 구현해주신 것 같아서 기능 이외에 부분에 코멘트를 남겼습니다.
후추와 같이(둘 다 querydsl 사용하니) 이야기를 나누고 고민해보셨으면 합니다.

Comment on lines 1 to 4
package dev.tripdraw.common.domain;

public record Paging(Long lastViewedId, Integer limit) {
}
Copy link
Member

Choose a reason for hiding this comment

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

해당 클래스가 domain 패키지에 위치하는건 조금 고민해볼 수 있을 것 같아요.
계층을 나누기 위해 Paging과 SearchPaging을 분리하신 것 같습니다!
VO 하나로 통일해보는건 어떠신가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

VO 하나로 통일하고, 패키지 분리했습니다!

Comment on lines 133 to 134
SearchConditions searchConditions = postSearchRequest.condition().toSearchConditions();
Paging paging = postSearchRequest.paging().toPaging();
Copy link
Member

Choose a reason for hiding this comment

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

만약 지금과 같이 SearchConditions의 계층 분리를 하신다면 getter를 사용한 후 메서드를 호출하는 것 보다 postSearchRequest에서 바로 postSearchRequest.toSearchConditions()이 더 가독성이 좋아보이는데 어떻게 생각하시나요?
아래의 paging도 동일한 의견입니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

VO를 하나로 통일하면서 해결됐습니다!

Comment on lines 1 to 10
package dev.tripdraw.post.domain;

import dev.tripdraw.common.domain.Paging;

import java.util.List;

public interface PostCustomRepository {

List<Post> findAllByConditions(SearchConditions conditions, Paging paging);
}
Copy link
Member

Choose a reason for hiding this comment

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

QueryDsl 관련 클래스(repositioy, repositoryImpl)들이 domain 패키지에 있는 부분에 대해 어떻게 생각하시나요? query용 패키지 및 queryService를 따로 분리하는 것도 좋을 것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

좋네요 분리했습니다!


@Override
public List<Post> findAllByConditions(SearchConditions conditions, Paging paging) {
QPost post = QPost.post;
Copy link
Member

Choose a reason for hiding this comment

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

QPost를 변수 추출하지 않고 static import 해보는건 어떠신가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

훨씬 깔끔해졌네요!

Comment on lines 39 to 43
if (lastViewedId == null) {
return null;
}

return post.id.lt(lastViewedId);
Copy link
Member

Choose a reason for hiding this comment

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

QueryDsl 마스터? 👍

Comment on lines +4 to +8

public record PostsSearchResponse(List<PostSearchResponse> posts, boolean hasNextPage) {
public static PostsSearchResponse of(List<PostSearchResponse> postSearchResponses, boolean hasNextPage) {
return new PostsSearchResponse(postSearchResponses, hasNextPage);
}
Copy link
Member

Choose a reason for hiding this comment

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

클라이언트와 hasNextPage에 대한 정보만 제공하기로 합의하셨군요 👍

Comment on lines +334 to +335
PostsSearchResponse postsSearchJejuResponse = postService.readAll(postSearchRequestJeju);
PostsSearchResponse postsSearchJulyResponse = postService.readAll(postSearchRequestJuly);
Copy link
Member

Choose a reason for hiding this comment

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

하나의 메서드에서 여러 개 검증을 하는 것보다 메서드를 분리해서 2개의 테스트 메서드를 작성하는 건 어떨까요?
Repository도 같은 의견입니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

같은 GIVEN 조건이라면 하나의 메서드 안에 있는 것을 선호하는 편입니다! 허브는 어떻게 생각하실까요?

Comment on lines 617 to 618
assertThat(postsSearchResponse.posts().get(0).postId()).isEqualTo(jejuSeptember17hourPostResponse.postId());
assertThat(postsSearchResponse.posts().get(1).postId()).isEqualTo(jejuAugust17hourPostResponse.postId());
Copy link
Member

Choose a reason for hiding this comment

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

controller나 service 검증부에 id만 검증하게 되는 경우 개인적인 경험으로 휴먼에러로 인해 실제로 데이터가 제공되지 않는 경우가 종종 있었어요. 모든 필드에 대해 검증해보는건 어떨까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

일단 ID로 비교하고 추후에 조금 더 추가하겠습니다!

return value.in(values);
}

private BooleanExpression eqAdress(StringPath address, String targetAddress) {
Copy link
Member

Choose a reason for hiding this comment

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

메서드명에 d 하나 빠졌네용~

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

매의 눈

Copy link
Member

@greeng00se greeng00se left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 👍

@Jaeyoung22 Jaeyoung22 merged commit 8eeb0ad into develop-backend Sep 19, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants