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
68
68
endTime . setMinutes ( endTime . getMinutes ( ) + duration ) ;
69
69
return endTime . toISOString ( ) ;
70
70
} ;
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 ) => ( {
74
75
bool : {
75
76
must : {
76
77
range : {
77
78
'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
+ } ,
80
90
} ,
81
91
} ,
82
92
} ,
You can’t perform that action at this time.
0 commit comments