Skip to content

Commit

Permalink
fix: ACTIVE 질문 조건 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
nahyeon99 committed Aug 4, 2024
1 parent 66b76c3 commit 4d4f5e0
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Optional<MeetingQuestion> findNextQuestion(Long meetingId) {
}

public ActiveMeetingQuestionResponse findActiveOneByMeeting(Long meetingId, Long loginMeetingMemberId) {
Optional<MeetingQuestion> activeMeetingQuestion = findActiveQuestion(meetingId);
Optional<MeetingQuestion> activeMeetingQuestion = findRegisteredMeetingQuestion(meetingId);

if (activeMeetingQuestion.isEmpty()) {
return null;
Expand All @@ -66,7 +66,15 @@ public ActiveMeetingQuestionResponse findActiveOneByMeeting(Long meetingId, Long
}

public Optional<MeetingQuestion> 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) {
Expand Down Expand Up @@ -115,12 +123,12 @@ public FullInactiveMeetingQuestionListResponse findFullInactiveList(Long meeting
return FullInactiveMeetingQuestionListResponse.of(inactiveMeetingQuestions, pageable);
}

private Optional<MeetingQuestion> findActiveQuestion(Long meetingId) {
private Optional<MeetingQuestion> findRegisteredMeetingQuestion(Long meetingId) {
return Optional.ofNullable(
queryFactory
.selectFrom(meetingQuestion)
.where(meetingQuestion.meeting.id.eq(meetingId),
activeCond())
registeredCond())
.orderBy(meetingQuestion.startTime.asc())
.limit(1)
.fetchOne()
Expand Down Expand Up @@ -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());
}

Expand Down

0 comments on commit 4d4f5e0

Please sign in to comment.