From 17c46362a352233e8aa1d3d14d8c74231e68dd57 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 14 Jul 2022 10:24:12 +0200 Subject: [PATCH] code cleanup --- .../session/impl/ExamSessionControlTask.java | 54 ------------------- .../session/impl/ExamUpdateHandler.java | 38 +------------ 2 files changed, 1 insertion(+), 91 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java index 8b1375fc..ac43a2e6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java @@ -107,8 +107,6 @@ public class ExamSessionControlTask implements DisposableBean { controlExamLMSUpdate(); controlExamState(updateId); -// controlExamStart(updateId); -// controlExamEnd(updateId); this.examDAO.releaseAgedLocks(); } @@ -215,58 +213,6 @@ public class ExamSessionControlTask implements DisposableBean { } } -// @Deprecated -// private void controlExamStart(final String updateId) { -// if (log.isTraceEnabled()) { -// log.trace("Check starting exams: {}", updateId); -// } -// -// try { -// -// final DateTime now = DateTime.now(DateTimeZone.UTC); -// final Map updated = this.examDAO.allForRunCheck() -// .getOrThrow() -// .stream() -// .filter(exam -> exam.startTime != null && exam.startTime.minus(this.examTimePrefix).isBefore(now)) -// .filter(exam -> exam.endTime == null || exam.endTime.plus(this.examTimeSuffix).isAfter(now)) -// .flatMap(exam -> Result.skipOnError(this.examUpdateHandler.setRunning(exam, updateId))) -// .collect(Collectors.toMap(Exam::getId, Exam::getName)); -// -// if (!updated.isEmpty()) { -// log.info("Updated exams to running state: {}", updated); -// } -// -// } catch (final Exception e) { -// log.error("Unexpected error while trying to update exams: ", e); -// } -// } -// -// @Deprecated -// private void controlExamEnd(final String updateId) { -// if (log.isTraceEnabled()) { -// log.trace("Check ending exams: {}", updateId); -// } -// -// try { -// -// final DateTime now = DateTime.now(DateTimeZone.UTC); -// -// final Map updated = this.examDAO.allForEndCheck() -// .getOrThrow() -// .stream() -// .filter(exam -> exam.endTime != null && exam.endTime.plus(this.examTimeSuffix).isBefore(now)) -// .flatMap(exam -> Result.skipOnError(this.examUpdateHandler.setFinished(exam, updateId))) -// .collect(Collectors.toMap(Exam::getId, Exam::getName)); -// -// if (!updated.isEmpty()) { -// log.info("Updated exams to finished state: {}", updated); -// } -// -// } catch (final Exception e) { -// log.error("Unexpected error while trying to update exams: ", e); -// } -// } - private void updateMaster() { this.webserviceInfo.updateMaster(); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java index 093d7037..a3dd4a3c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamUpdateHandler.java @@ -91,6 +91,7 @@ class ExamUpdateHandler { this.lmsAPIService .getLmsAPITemplate(lmsSetupId) .map(template -> { + // TODO flush only involved courses from cache! template.clearCourseCache(); return template; }) @@ -213,43 +214,6 @@ class ExamUpdateHandler { exam, error)); } - -// switch (exam.status) { -// case UP_COMING: { -// // move to RUNNING when now is within the running time frame -// if (withinTimeframe(exam.startTime, startTimeThreshold, exam.endTime, endTimeThreshold)) { -// setRunning(exam, updateId) -// .onError(error -> log.error("Failed to update exam to running state: {}", exam, error)); -// break; -// } -// // move to FINISHED when now is behind the end date -// if (exam.endTime != null && endTimeThreshold.isAfter(exam.endTime)) { -// setFinished(exam, updateId) -// .onError( -// error -> log.error("Failed to update exam to finished state: {}", exam, error)); -// break; -// } -// } -// case RUNNING: { -// // move to FINISHED when now is behind the end date -// if (exam.endTime != null && endTimeThreshold.isAfter(exam.endTime)) { -// setFinished(exam, updateId) -// .onError( -// error -> log.error("Failed to update exam to finished state: {}", exam, error)); -// break; -// } -// // move to UP_COMMING when now is before the start date -// break; -// } -// case FINISHED: { -// // move to RUNNING when now is within the running time frame -// // move to UP_COMMING when now is before the start date -// break; -// } -// default: { -// log.warn("Exam for status update in unexpected state. Skip update. Exam: {}", exam); -// } -// } } catch (final Exception e) { log.error("Unexpected error while trying to update exam state for exam: {}", exam, e); }