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

[refactor] querydsl 및 프로젝션 적용 #155

Merged
merged 8 commits into from
Jan 13, 2025
Merged

Conversation

chaewonni
Copy link
Member

@chaewonni chaewonni commented Jan 3, 2025

Related issue 🛠

Work Description ✏️

  • 기존 DTO 기반 데이터 조회를 Projection 방식으로 변경했습니다.
  • 변경에 따라 필요 없게 된 DTO들을 삭제하였습니다.
  • participantRepository 내에서 동적 조건이나 복잡한 조건이 필요한 쿼리에 QueryDSL을 적용하였습니다.

Uncompleted Tasks 😅

  • 또 querydsl을 적용하면 좋을 부분이 있는지 살펴보기

To Reviewers 📢

Copy link
Contributor

@tkdwns414 tkdwns414 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다. 좋아요~

Comment on lines -213 to -239

private ParticipantDto createParticipantDto(final ParticipantStatusUserInfoDto dto) {
String state = determineState(dto.preparationAt(), dto.departureAt(), dto.arrivalAt()); // 상태 결정 로직 호출

return ParticipantDto.of(dto.participantId(), dto.memberId(), dto.name(), dto.profileImg(), state);
}

private String determineState(
final LocalDateTime preparationAt,
final LocalDateTime departureAt,
final LocalDateTime arrivalAt
) {
if (arrivalAt != null) {
return "도착";
} else if (departureAt != null) {
return "이동중";
} else if (preparationAt != null) {
return "준비중";
}
return "꾸물중";
}

private int stateOrder(String state) {
switch(state) {
case "도착": return 1;
case "이동중": return 2;
case "준비중": return 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

DB에서 처리돼서 오는거긴 하지만 보이는 코드는 깔끔해졌네용

Copy link
Member Author

Choose a reason for hiding this comment

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

넵 기존 애플리케이션으로 가져와 처리하는 것보다 DB에서 처리하는 게 성능적인 이점과 코드 가독성 면에서 더 나은 방식이라고 판단하여 수정해보았습니다!

Comment on lines +21 to +28
SELECT
m.id as id, m.name as name, m.createdAt as createdAt,
m.invitationCode as invitationCode, COUNT(p.id) as metCount
FROM Meeting m
LEFT JOIN Promise p ON p.meeting.id = m.id AND p.isCompleted = true
WHERE m.id = :meetingId
GROUP BY m.id """)
Optional<MeetingMetCountDto> findByIdWithMetCount(Long meetingId);
Optional<MeetingMetCountProjection> findByIdWithMetCount(Long meetingId);
Copy link
Contributor

Choose a reason for hiding this comment

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

나중에 쿼리 적는 방법도 같이 정해봐요

@chaewonni chaewonni merged commit bc2bea9 into develop Jan 13, 2025
1 check passed
@chaewonni chaewonni deleted the refactor/154 branch January 13, 2025 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[refactor] querydsl 및 프로젝션 적용
2 participants