Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bo-ram-bo-ram committed Oct 9, 2024
2 parents 0c84ae6 + d2cb772 commit 34a10e3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public List<MoimListByHostGetResponse> getMoimListByHost(Long hostId) {

private Long calculateApprovedGuest(Long moimId) {
try {
return moimSubmissionRepository.countApprovedMoimSubmissions(moimId);
return moimSubmissionRepository.countValidMoimSubmissions(moimId);
} catch (InvalidDataAccessResourceUsageException e) {
// 테이블이 존재하지 않아서 발생한 예외일 경우 0 반환
return 0L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ default MoimSubmission findMoimSubmissionByIdOrThrow(Long id) {
@Query("SELECT ms FROM MoimSubmission ms WHERE ms.guestId = :guestId AND ms.moimSubmissionState = 'completed'")
List<MoimSubmission> findCompletedMoimSubmissionsByGuest(@Param("guestId") Long guestId);

@Query("SELECT COUNT(ms) FROM MoimSubmission ms WHERE ms.moim.id = :moimId AND ms.moimSubmissionState = 'approved'")
long countApprovedMoimSubmissions(@Param("moimId") Long moimId);
@Query("SELECT COUNT(ms) FROM MoimSubmission ms WHERE ms.moim.id = :moimId AND ms.moimSubmissionState IN('approved','completed')")
long countValidMoimSubmissions(@Param("moimId") Long moimId);

@Query("SELECT COUNT(ms) FROM MoimSubmission ms WHERE ms.moim.id IN :moimIds AND ms.moimSubmissionState = 'completed'")
int countCompletedSubmissionsByMoimIds(@Param("moimIds") List<Long> moimIds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,24 @@ private MoimSubmissionAllResponse mapToMoimSubmissionAllResponse(MoimSubmission
.build();
}


private boolean isApprovable(Moim moim) {
// 모임일
LocalDate date = moim.getDateList().getDate();

// 마감일: 신청일 + 3일의 자정
LocalDateTime deadline = date.minusDays(3).atTime(LocalTime.MIDNIGHT);
// 모임 시작 시간
LocalTime startTime = moim.getDateList().getStartTime();

// 승인 가능 시작 시간: 모임일 전날 자정 (모임일 하루 전 자정)
LocalDateTime approvalStartTime = date.minusDays(1).atStartOfDay();

// 승인 가능 종료 시간: 모임일의 시작 시간
LocalDateTime approvalEndTime = date.atTime(startTime);

// 현재 시간
LocalDateTime now = LocalDateTime.now();

// 승인 가능 여부: 현재 시간이 마감일 이후인지 확인
return now.isAfter(deadline);
// 승인 가능 여부: 현재 시간이 승인 시작 시간 이후 또는 같은 시간이고, 승인 종료 시간 이전인지 확인
return (now.isEqual(approvalStartTime) || now.isAfter(approvalStartTime)) && now.isBefore(approvalEndTime);
}

public SubmitterInfo getSubmitterInfo(Long guestId, Long moimId) {
Expand Down

0 comments on commit 34a10e3

Please sign in to comment.