From ea65d1e81ccf712c0d33780b87a5ed8abd9cb01c Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 27 Oct 2021 09:11:00 +0200 Subject: [PATCH] code analysis --- .../sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java | 1 + .../servicelayer/session/impl/ExamSessionServiceImpl.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java index a258846e..f10e325c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamDAOImpl.java @@ -637,6 +637,7 @@ public class ExamDAOImpl implements ExamDAO { @Override @Transactional(readOnly = true) public Result upToDate(final Long examId, final String updateId) { + // TODO make this with count on examId and updateId equals --> if count is 1 then it is up to date otherwise not return this.recordById(examId) .map(rec -> { if (updateId == null) { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java index 67a62448..8c29fe3c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java @@ -361,11 +361,13 @@ public class ExamSessionServiceImpl implements ExamSessionService { @Override public Result updateExamCache(final Long examId) { + // Get from cache (or load to cache if not already present) final Exam exam = this.examSessionCacheService.getRunningExam(examId); if (exam == null) { return Result.ofEmpty(); } + // Check if the exam from cache is up to date by checking the last_update on persistent storage final Boolean isUpToDate = this.examDAO.upToDate(examId, exam.lastUpdate) .onError(t -> log.error("Failed to verify if cached exam is up to date: {}", exam, t)) .getOr(false);