Skip to content

Commit

Permalink
fix: 인스턴스 참여 여부 확인 메서드 수정
Browse files Browse the repository at this point in the history
- 인스턴스 참여 여부를 확인하는 로직에 오류가 있어 수정
- 참여 상태가 No일 때에도 참여로 간주하고 있어, No가 아닐 때에만 true를 반환하도록 수정
  • Loading branch information
SSung023 committed Jun 27, 2024
1 parent c7ec355 commit 5c18745
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public InstanceResponse getInstanceDetailInformation(User user, Long instanceId)
FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles());
LikesInfo likesInfo = getLikesInfo(user.getId(), instance);

if (participantProvider.hasParticipant(user.getId(), instanceId)) {
if (participantProvider.hasJoinedParticipant(user.getId(), instanceId)) {
return InstanceResponse.createByEntity(instance, likesInfo, JoinStatus.YES, fileResponse);
}

Expand Down Expand Up @@ -90,7 +90,7 @@ private void validateJoinDate(Instance instance, LocalDate todayDate) {
}

private void validateInstanceCondition(User user, Instance instance) {
boolean isParticipated = participantProvider.hasParticipant(user.getId(), instance.getId());
boolean isParticipated = participantProvider.hasJoinedParticipant(user.getId(), instance.getId());
if ((instance.getProgress() == Progress.PREACTIVITY) && !isParticipated) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.genius.gitget.challenge.participant.domain.Participant;
import com.genius.gitget.challenge.participant.repository.ParticipantRepository;
import com.genius.gitget.global.util.exception.BusinessException;
import java.time.LocalDate;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -65,12 +64,9 @@ public List<Participant> findJoinedByProgress(Long userId, Progress progress) {
return participantRepository.findAllJoinedByProgress(userId, progress);
}

public boolean hasParticipant(Long userId, Long instanceId) {
return participantRepository.findByJoinInfo(userId, instanceId).isPresent();
}

public LocalDate getInstanceStartDate(Long participantId) {
return getInstanceById(participantId).getStartedDate().toLocalDate();
public boolean hasJoinedParticipant(Long userId, Long instanceId) {
return participantRepository.findByJoinInfo(userId, instanceId)
.map(participant -> participant.getJoinStatus() != JoinStatus.NO)
.orElse(false);
}

}

0 comments on commit 5c18745

Please sign in to comment.