Skip to content

Commit

Permalink
[REFATOR] 당일 출석 정보 누락된 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dragontaek-lee committed Feb 15, 2024
1 parent 3f3e9fc commit 2452b71
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ public TodayLectureResponse getTodayLecture(long memberPlaygroundId) {
}

val subAttendances = attendance.getSubAttendances();
val subAttendance = lecture.isFirst() ? subAttendances.get(0) : subAttendances.get(1);
return getTodayLectureResponse(subAttendance, responseType, lecture);

if (lecture.isFirst()) {
return getTodayFirstLectureResponse(subAttendances.get(0), responseType, lecture);
}

return getTodaySecondLectureResponse(subAttendances, responseType, lecture);
}

private TodayLectureResponse getEmptyResponse() {
Expand Down Expand Up @@ -104,7 +108,7 @@ private String getMessage(Attribute attribute) {
};
}

private TodayLectureResponse getTodayLectureResponse(SubAttendance subAttendance, LectureResponseType responseType, Lecture lecture) {
private TodayLectureResponse getTodayFirstLectureResponse(SubAttendance subAttendance, LectureResponseType responseType, Lecture lecture) {
val subLecture = subAttendance.getSubLecture();
val isOnAttendanceCheck = LocalDateTime.now().isBefore(subLecture.getStartAt().plusMinutes(10));
val message = getMessage(lecture.getAttribute());
Expand All @@ -114,6 +118,21 @@ private TodayLectureResponse getTodayLectureResponse(SubAttendance subAttendance
return TodayLectureResponse.of(responseType, lecture, message, Collections.singletonList(subAttendance));
}

private TodayLectureResponse getTodaySecondLectureResponse(
List<SubAttendance> subAttendances,
LectureResponseType responseType,
Lecture lecture
) {
val subAttendance = subAttendances.get(1);
val subLecture = subAttendance.getSubLecture();
val isOnAttendanceCheck = LocalDateTime.now().isBefore(subLecture.getStartAt().plusMinutes(10));
val message = getMessage(lecture.getAttribute());
if (isOnAttendanceCheck && subAttendance.getStatus().equals(ABSENT)) {
return TodayLectureResponse.of(responseType, lecture, message, Collections.singletonList(subAttendances.get(0)));
}
return TodayLectureResponse.of(responseType, lecture, message, subAttendances);
}

@Override
public LectureCurrentRoundResponse getCurrentLectureRound(long lectureId) {
val lecture = findLecture(lectureId);
Expand Down

0 comments on commit 2452b71

Please sign in to comment.