From 4d4f5e0d6c478cb6f1df1d926ebec960e446d89c Mon Sep 17 00:00:00 2001 From: nahyeon99 Date: Sun, 4 Aug 2024 20:35:10 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20ACTIVE=20=EC=A7=88=EB=AC=B8=20=EC=A1=B0?= =?UTF-8?q?=EA=B1=B4=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MeetingQuestionQueryRepository.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/depromeet/sambad/moring/meeting/question/infrastructure/MeetingQuestionQueryRepository.java b/src/main/java/org/depromeet/sambad/moring/meeting/question/infrastructure/MeetingQuestionQueryRepository.java index f1ab4816..30873f3b 100644 --- a/src/main/java/org/depromeet/sambad/moring/meeting/question/infrastructure/MeetingQuestionQueryRepository.java +++ b/src/main/java/org/depromeet/sambad/moring/meeting/question/infrastructure/MeetingQuestionQueryRepository.java @@ -53,7 +53,7 @@ public Optional findNextQuestion(Long meetingId) { } public ActiveMeetingQuestionResponse findActiveOneByMeeting(Long meetingId, Long loginMeetingMemberId) { - Optional activeMeetingQuestion = findActiveQuestion(meetingId); + Optional activeMeetingQuestion = findRegisteredMeetingQuestion(meetingId); if (activeMeetingQuestion.isEmpty()) { return null; @@ -66,7 +66,15 @@ public ActiveMeetingQuestionResponse findActiveOneByMeeting(Long meetingId, Long } public Optional findActiveOneByMeeting(Long meetingId) { - return findActiveQuestion(meetingId); + return Optional.ofNullable( + queryFactory + .selectFrom(meetingQuestion) + .where(meetingQuestion.meeting.id.eq(meetingId), + activeCond()) + .orderBy(meetingQuestion.startTime.asc()) + .limit(1) + .fetchOne() + ); } public MostInactiveMeetingQuestionListResponse findMostInactiveList(Long meetingId) { @@ -115,12 +123,12 @@ public FullInactiveMeetingQuestionListResponse findFullInactiveList(Long meeting return FullInactiveMeetingQuestionListResponse.of(inactiveMeetingQuestions, pageable); } - private Optional findActiveQuestion(Long meetingId) { + private Optional findRegisteredMeetingQuestion(Long meetingId) { return Optional.ofNullable( queryFactory .selectFrom(meetingQuestion) .where(meetingQuestion.meeting.id.eq(meetingId), - activeCond()) + registeredCond()) .orderBy(meetingQuestion.startTime.asc()) .limit(1) .fetchOne() @@ -152,11 +160,15 @@ private Boolean isAnswered(Long meetingQuestionId, Long meetingMemberId) { return fetchOne != null; } - private BooleanExpression activeCond() { + private BooleanExpression registeredCond() { LocalDateTime now = LocalDateTime.now(); return meetingQuestion.startTime.loe(now) .and(meetingQuestion.startTime.goe(now.minusHours(RESPONSE_TIME_LIMIT_HOURS))) - .and(isAnsweredByAllCond().not()) + .and(isAnsweredByAllCond().not()); + } + + private BooleanExpression activeCond() { + return registeredCond() .and(meetingQuestion.question.isNotNull()); }