File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
website/src/views/modules Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -68,15 +68,25 @@ function getExamClashFilter(semester: Semester, examTimings: ExamTiming[]): Filt
6868 endTime . setMinutes ( endTime . getMinutes ( ) + duration ) ;
6969 return endTime . toISOString ( ) ;
7070 } ;
71- // Map each exam to an Elasticsearch range query.
72- // Exam2 clashes with exam1 when (exam2.start < exam1.end) && (exam2.end > exam1.start)
73- const clashRanges = examTimings . map ( ( exam ) => ( {
71+ // For each exam1, map it to an Elasticsearch query that will return True
72+ // if another exam clashes with exam1. For example, exam2 clashes (i.e. overlaps)
73+ // with exam1 iff (exam2.start < exam1.end) && (exam2.end > exam1.start)
74+ const clashRanges = examTimings . map ( ( exam1 ) => ( {
7475 bool : {
7576 must : {
7677 range : {
7778 'semesterData.examDate' : {
78- gte : exam . start , // TODO find a way to subtract semesterData.duration
79- lt : getEndTime ( exam . start , exam . duration ) ,
79+ lt : getEndTime ( exam1 . start , exam1 . duration ) ,
80+ } ,
81+ } ,
82+ script : {
83+ script : {
84+ source : `doc.containsKey['semesterData.examDate'] &&
85+ doc.containsKey['semesterData.examDuration'] &&
86+ ZonedDateTime.parse(doc['semesterData.examDate'].value).plusMinutes(doc['semesterData.examDuration].value).isAfter(ZonedDateTime.parse(params.exam1start))` ,
87+ params : {
88+ exam1start : exam1 . start ,
89+ } ,
8090 } ,
8191 } ,
8292 } ,
You can’t perform that action at this time.
0 commit comments