Skip to content

Commit

Permalink
fix: delete 쿼리 발생 x 오류 해결 (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
SunwoongH committed Mar 9, 2024
1 parent d061f22 commit fd7a21b
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public TripParticipantGetResponse getParticipants(Long userId, Long tripId) {
public void leaveTrip(Long userId, Long tripId) {
User findUser = getUser(userId);
Trip findTrip = getTrip(tripId);
int size = calculateParticipantsCount(findTrip);
int size = participantRepository.countByTrip(findTrip);
Participant findParticipant = getParticipant(findUser, findTrip);
List<Todo> todos = todoRepository.findMyTodoByTripIdAndUserIdAndSecret(tripId, userId, Secret.MY);
todoRepository.deleteAll(todos);
Expand Down Expand Up @@ -130,10 +130,6 @@ private User getUser(Long userId) {
.orElseThrow(() -> new EntityNotFoundException(ErrorMessage.USER_NOT_FOUND));
}

private int calculateParticipantsCount(Trip findTrip) {
return findTrip.getParticipants().size();
}

private Participant getParticipant(User findUser, Trip findTrip) {
return participantRepository.findByUserAndTrip(findUser, findTrip)
.orElseThrow(() -> new EntityNotFoundException(ErrorMessage.PARTICIPANT_NOT_FOUND));
Expand Down Expand Up @@ -166,8 +162,7 @@ private boolean isEqualUserAndParticipantUser(User user, User participantUser) {
private int getValidatedResult(User user) {
if (user.getResult() == null) {
return -1;
}
else {
} else {
return user.getResult().getNumResult();
}
}
Expand Down

0 comments on commit fd7a21b

Please sign in to comment.