SEBSERV-343 fixed also page number out of date/range

This commit is contained in:
anhefti 2022-07-20 13:39:58 +02:00
parent b6a3e7ab64
commit 333d08cfe7
2 changed files with 15 additions and 7 deletions

View file

@ -119,9 +119,14 @@ public interface PaginationService {
final List<T> 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();

View file

@ -202,15 +202,18 @@ public class ExamRecordDAO {
isNotEqualTo(ExamStatus.ARCHIVED.name()));
}
final List<ExamRecord> records = whereClause
if (filterMap.getExamFromTime() != null) {
whereClause = whereClause
.and(
ExamRecordDynamicSqlSupport.quizEndTime,
isGreaterThanOrEqualToWhenPresent(filterMap.getExamFromTime()),
or(ExamRecordDynamicSqlSupport.quizEndTime, isNull()));
}
final List<ExamRecord> records = whereClause
.and(
ExamRecordDynamicSqlSupport.quizName,
isLikeWhenPresent(filterMap.getSQLWildcard(EXAM.ATTR_QUIZ_NAME)))
.and(
ExamRecordDynamicSqlSupport.quizEndTime,
isGreaterThanOrEqualToWhenPresent(filterMap.getExamFromTime()),
or(ExamRecordDynamicSqlSupport.quizEndTime, isNull()))
.build()
.execute();