diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationService.java index fbf24ec2..eb4d8e71 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationService.java @@ -119,9 +119,14 @@ public interface PaginationService { final List sorted = pageFunction.apply(all); - final int _pageNumber = getPageNumber(pageNumber); + int _pageNumber = getPageNumber(pageNumber); final int _pageSize = getPageSize(pageSize); - final int start = (_pageNumber - 1) * _pageSize; + + int start = (_pageNumber - 1) * _pageSize; + if (start >= sorted.size()) { + start = 0; + _pageNumber = 1; + } int end = start + _pageSize; if (sorted.size() < end) { end = sorted.size(); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java index 5550af7b..3b791e0a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java @@ -202,15 +202,18 @@ public class ExamRecordDAO { isNotEqualTo(ExamStatus.ARCHIVED.name())); } - final List records = whereClause + if (filterMap.getExamFromTime() != null) { + whereClause = whereClause + .and( + ExamRecordDynamicSqlSupport.quizEndTime, + isGreaterThanOrEqualToWhenPresent(filterMap.getExamFromTime()), + or(ExamRecordDynamicSqlSupport.quizEndTime, isNull())); + } + final List records = whereClause .and( ExamRecordDynamicSqlSupport.quizName, isLikeWhenPresent(filterMap.getSQLWildcard(EXAM.ATTR_QUIZ_NAME))) - .and( - ExamRecordDynamicSqlSupport.quizEndTime, - isGreaterThanOrEqualToWhenPresent(filterMap.getExamFromTime()), - or(ExamRecordDynamicSqlSupport.quizEndTime, isNull())) .build() .execute();