Skip to content

Commit

Permalink
[REFACTOR] 출석 중 결석 판별 메소드화
Browse files Browse the repository at this point in the history
  • Loading branch information
dragontaek-lee committed Feb 15, 2024
1 parent 9d03d55 commit dca3eda
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ private void checkAttendancesSize(List<Attendance> attendances) {
}
}

private boolean checkOnAttendanceAbsence(SubLecture subLecture, SubAttendance subAttendance) {
val isOnAttendanceCheck = LocalDateTime.now().isBefore(subLecture.getStartAt().plusMinutes(10));
return isOnAttendanceCheck && subAttendance.getStatus().equals(ABSENT);
}

private Attendance getNowAttendance(List<Attendance> attendances) {
val index = getAttendanceIndex();
return attendances.get(index);
Expand All @@ -97,9 +102,8 @@ private String getMessage(Attribute attribute) {

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());
if (isOnAttendanceCheck && subAttendance.getStatus().equals(ABSENT)) {
if (checkOnAttendanceAbsence(subLecture, subAttendance)) {
return TodayLectureResponse.of(responseType, lecture, message, Collections.emptyList());
}
return TodayLectureResponse.of(responseType, lecture, message, Collections.singletonList(subAttendance));
Expand All @@ -112,9 +116,8 @@ private TodayLectureResponse getTodaySecondLectureResponse(
) {
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)) {
if (checkOnAttendanceAbsence(subLecture, subAttendance)) {
return TodayLectureResponse.of(responseType, lecture, message, Collections.singletonList(subAttendances.get(0)));
}
return TodayLectureResponse.of(responseType, lecture, message, subAttendances);
Expand Down

0 comments on commit dca3eda

Please sign in to comment.