code analysis
This commit is contained in:
parent
b06e6d5424
commit
ea65d1e81c
2 changed files with 3 additions and 0 deletions
|
@ -637,6 +637,7 @@ public class ExamDAOImpl implements ExamDAO {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public Result<Boolean> upToDate(final Long examId, final String updateId) {
|
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)
|
return this.recordById(examId)
|
||||||
.map(rec -> {
|
.map(rec -> {
|
||||||
if (updateId == null) {
|
if (updateId == null) {
|
||||||
|
|
|
@ -361,11 +361,13 @@ public class ExamSessionServiceImpl implements ExamSessionService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<Exam> updateExamCache(final Long examId) {
|
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);
|
final Exam exam = this.examSessionCacheService.getRunningExam(examId);
|
||||||
if (exam == null) {
|
if (exam == null) {
|
||||||
return Result.ofEmpty();
|
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)
|
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))
|
.onError(t -> log.error("Failed to verify if cached exam is up to date: {}", exam, t))
|
||||||
.getOr(false);
|
.getOr(false);
|
||||||
|
|
Loading…
Reference in a new issue