code analysis

This commit is contained in:
anhefti 2021-10-27 09:11:00 +02:00
parent b06e6d5424
commit ea65d1e81c
2 changed files with 3 additions and 0 deletions

View file

@ -637,6 +637,7 @@ public class ExamDAOImpl implements ExamDAO {
@Override
@Transactional(readOnly = true)
public Result<Boolean> 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) {

View file

@ -361,11 +361,13 @@ public class ExamSessionServiceImpl implements ExamSessionService {
@Override
public Result<Exam> 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);