From 07b31b51f8aec7866831d385d631211dcfdf3480 Mon Sep 17 00:00:00 2001 From: Matti Lupari Date: Thu, 23 Jan 2025 19:37:16 +0200 Subject: [PATCH 1/2] CSCEXAM-1375 Make examination start delay as milliseconds for perf --- app/models/enrolment/ExamEnrolment.java | 2 +- app/repository/EnrolmentRepository.java | 13 ++++--------- conf/evolutions/default/136.sql | 9 +++++++++ .../waiting-room/waiting-room.component.ts | 6 +++--- 4 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 conf/evolutions/default/136.sql diff --git a/app/models/enrolment/ExamEnrolment.java b/app/models/enrolment/ExamEnrolment.java index 5c612af20..96805a626 100644 --- a/app/models/enrolment/ExamEnrolment.java +++ b/app/models/enrolment/ExamEnrolment.java @@ -33,7 +33,7 @@ @Entity public class ExamEnrolment extends GeneratedIdentityModel implements Comparable { - private static final int DELAY_MAX = 30; + private static final int DELAY_MAX = 30 * 1000; @ManyToOne @JsonManagedReference diff --git a/app/repository/EnrolmentRepository.java b/app/repository/EnrolmentRepository.java index 49c93d7a9..15d71f4c2 100644 --- a/app/repository/EnrolmentRepository.java +++ b/app/repository/EnrolmentRepository.java @@ -288,11 +288,6 @@ private void handleUpcomingEnrolment( if ( enrolment.getExam() != null && enrolment.getExam().getImplementation() == Exam.Implementation.AQUARIUM ) { - // If user is on a correct aquarium machine then always set a header - headers.put( - "x-exam-aquarium-login", - String.format("%s:::%d", getExamHash(enrolment), enrolment.getId()) - ); // Aquarium exam, don't set headers unless it starts in 5 minutes DateTime threshold = DateTime.now().plusMinutes(5); DateTime start = dateTimeHandler.normalize( @@ -327,22 +322,22 @@ private boolean isInsideBounds(ExamEnrolment ee, int minutesToFuture) { int delay = ee.getDelay(); return ( (reservation != null && - reservation.getStartAt().plusSeconds(delay).isBefore(latest) && + reservation.getStartAt().plusMillis(delay).isBefore(latest) && reservation.getEndAt().isAfter(earliest)) || (event != null && - event.getStart().plusSeconds(delay).isBefore(latest) && + event.getStart().plusMillis(delay).isBefore(latest) && event.getStart().plusMinutes(ee.getExam().getDuration()).isAfter(earliest)) ); } private DateTime getStartTime(ExamEnrolment enrolment) { return enrolment.getReservation() != null - ? enrolment.getReservation().getStartAt().plusSeconds(enrolment.getDelay()) + ? enrolment.getReservation().getStartAt().plusMillis(enrolment.getDelay()) : enrolment .getExaminationEventConfiguration() .getExaminationEvent() .getStart() - .plusSeconds(enrolment.getDelay()); + .plusMillis(enrolment.getDelay()); } private Optional getNextEnrolment(Long userId, int minutesToFuture) { diff --git a/conf/evolutions/default/136.sql b/conf/evolutions/default/136.sql new file mode 100644 index 000000000..b8340b118 --- /dev/null +++ b/conf/evolutions/default/136.sql @@ -0,0 +1,9 @@ +-- SPDX-FileCopyrightText: 2024 The members of the EXAM Consortium +-- +-- SPDX-License-Identifier: EUPL-1.2 + +# --- !Ups +UPDATE exam_enrolment SET delay = delay * 1000; + +# --- !Downs +UPDATE exam_enrolment SET delay = delay / 1000; diff --git a/ui/src/app/enrolment/waiting-room/waiting-room.component.ts b/ui/src/app/enrolment/waiting-room/waiting-room.component.ts index ebb2baa69..b627ba2a2 100644 --- a/ui/src/app/enrolment/waiting-room/waiting-room.component.ts +++ b/ui/src/app/enrolment/waiting-room/waiting-room.component.ts @@ -22,8 +22,8 @@ import { MathJaxDirective } from 'src/app/shared/math/math-jax.directive'; import { CourseCodeComponent } from 'src/app/shared/miscellaneous/course-code.component'; import { TeacherListComponent } from 'src/app/shared/user/teacher-list.component'; -export type WaitingReservation = Reservation & { occasion: { startAt: string; endAt: string } }; -export type WaitingEnrolment = Omit & { +type WaitingReservation = Reservation & { occasion: { startAt: string; endAt: string } }; +type WaitingEnrolment = Omit & { reservation: WaitingReservation; }; @@ -102,7 +102,7 @@ export class WaitingRoomComponent implements OnInit, OnDestroy { private startScheduled = () => { window.clearTimeout(this.startTimerId); const offset = Math.ceil( - DateTime.fromJSDate(this.getStart()).plus({ seconds: this.enrolment.delay }).toSeconds() - + DateTime.fromJSDate(this.getStart()).plus({ milliseconds: this.enrolment.delay }).toSeconds() - DateTime.now().toSeconds(), ); this.delayTimerId = window.setTimeout(this.Session.checkSession, Math.max(0, offset * 1000)); From 1be5dbc6683d9f8c0a721eb27225ccb6bef5d17f Mon Sep 17 00:00:00 2001 From: Matti Lupari Date: Thu, 23 Jan 2025 21:56:53 +0200 Subject: [PATCH 2/2] CSCEXAM-000 Fix build problem with new early-waitingroom --- ui/src/app/enrolment/waiting-room/waiting-room.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/app/enrolment/waiting-room/waiting-room.component.ts b/ui/src/app/enrolment/waiting-room/waiting-room.component.ts index b627ba2a2..9f2175752 100644 --- a/ui/src/app/enrolment/waiting-room/waiting-room.component.ts +++ b/ui/src/app/enrolment/waiting-room/waiting-room.component.ts @@ -22,8 +22,8 @@ import { MathJaxDirective } from 'src/app/shared/math/math-jax.directive'; import { CourseCodeComponent } from 'src/app/shared/miscellaneous/course-code.component'; import { TeacherListComponent } from 'src/app/shared/user/teacher-list.component'; -type WaitingReservation = Reservation & { occasion: { startAt: string; endAt: string } }; -type WaitingEnrolment = Omit & { +export type WaitingReservation = Reservation & { occasion: { startAt: string; endAt: string } }; +export type WaitingEnrolment = Omit & { reservation: WaitingReservation; };