Skip to content

Commit

Permalink
[#247] 강의 겹침 판단 로직 변경 (실제 시간 기준)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hank-Choi committed Nov 29, 2022
1 parent 53f5117 commit a7e3d8a
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/core/timetable/TimetableLectureService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,7 @@ function makeOverwritingConfirmMessage(overlappingLectures: UserLecture[]) {
}

function getOverlappingLectures(table: Timetable, lecture: UserLecture): UserLecture[] {
let lectures: UserLecture[] = [];
for (let i=0; i<table.lecture_list.length; i++) {
const tableLecture: any = table.lecture_list[i];
for (let j=0; j<tableLecture.class_time_mask.length; j++) {
if ((tableLecture.class_time_mask[j] & lecture.class_time_mask[j]) != 0) {
lectures.push(tableLecture);
break;
}
}
}
return lectures;
return table.lecture_list.filter(existingLecture => twoLecturesOverlap(existingLecture, lecture) )
}

function validateLectureTimeJson(timePlace: TimePlace): void {
Expand Down Expand Up @@ -248,6 +238,18 @@ export function getUserLectureFromTimetableByCourseNumber(table: Timetable, cour
return null;
}

function twoLecturesOverlap(lectureA: Lecture, lectureB: Lecture): boolean {
return lectureA.class_time_json.some(classTimeA =>
lectureB.class_time_json.some(classTimeB => timesOverlap(classTimeA, classTimeB))
)
}

function timesOverlap(time1:TimePlace, time2: TimePlace): boolean {
return time1.day === time2.day
&& (Time.fromHourMinuteString(time1.start_time).minute < Time.fromHourMinuteString(time2.end_time).minute)
&& (Time.fromHourMinuteString(time1.end_time).minute > Time.fromHourMinuteString(time2.start_time).minute)
}

function syncRealTimeWithPeriod(lecture: any): void {
lecture.class_time_json.forEach(it => {
it.start_time = it.start_time || new Time((it.start + 8) * 60).toHourMinuteFormat()
Expand Down

0 comments on commit a7e3d8a

Please sign in to comment.