-
Notifications
You must be signed in to change notification settings - Fork 0
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
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.
수고하셨습니다. 좋아요~
|
||
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; |
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에서 처리돼서 오는거긴 하지만 보이는 코드는 깔끔해졌네용
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에서 처리하는 게 성능적인 이점과 코드 가독성 면에서 더 나은 방식이라고 판단하여 수정해보았습니다!
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); |
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.
나중에 쿼리 적는 방법도 같이 정해봐요
Related issue 🛠
Work Description ✏️
Uncompleted Tasks 😅
To Reviewers 📢