Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SAMBAD-224] 현재 모임 질문 조회 버그 수정 #96

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = findRegisteredMeetingQuestion(meetingId);
Optional<MeetingQuestion> activeMeetingQuestion = findMeetingQuestion(meetingId);

if (activeMeetingQuestion.isEmpty()) {
return null;
Expand Down Expand Up @@ -111,6 +111,18 @@ public Optional<MeetingQuestion> findRegisteredMeetingQuestion(Long meetingId) {
);
}

public Optional<MeetingQuestion> findMeetingQuestion(Long meetingId) {
return Optional.ofNullable(
queryFactory
.selectFrom(meetingQuestion)
.where(meetingQuestion.meeting.id.eq(meetingId),
registeredOrActiveCond())
.orderBy(meetingQuestion.startTime.asc())
.limit(1)
.fetchOne()
);
}

public FullInactiveMeetingQuestionListResponse findFullInactiveList(Long meetingId, Pageable pageable) {
QFileEntity profileImageFile = new QFileEntity("profileImageFile");
QFileEntity questionImageFile = new QFileEntity("questionImageFile");
Expand Down Expand Up @@ -160,6 +172,12 @@ private Boolean isAnswered(Long meetingQuestionId, Long meetingMemberId) {
return fetchOne != null;
}

private BooleanExpression registeredOrActiveCond() {
LocalDateTime now = LocalDateTime.now();
return meetingQuestion.startTime.loe(now)
.and(meetingQuestion.startTime.goe(now.minusHours(RESPONSE_TIME_LIMIT_HOURS)));
}

private BooleanExpression registeredCond() {
LocalDateTime now = LocalDateTime.now();
return meetingQuestion.startTime.loe(now)
Expand Down
Loading