Add offset/limit to logs page

[MAILPOET-3135]
This commit is contained in:
Pavel Dohnal
2021-03-08 12:03:31 +01:00
committed by Veljko V
parent 89f5da7b76
commit 61c8b3702a
6 changed files with 78 additions and 3 deletions

View File

@ -18,9 +18,17 @@ class LogRepository extends Repository {
* @param \DateTimeInterface|null $dateFrom
* @param \DateTimeInterface|null $dateTo
* @param string|null $search
* @param string $offset
* @param string $limit
* @return LogEntity[]
*/
public function getLogs(\DateTimeInterface $dateFrom = null, \DateTimeInterface $dateTo = null, string $search = null): array {
public function getLogs(
\DateTimeInterface $dateFrom = null,
\DateTimeInterface $dateTo = null,
string $search = null,
string $offset = null,
string $limit = null
): array {
$query = $this->doctrineRepository->createQueryBuilder('l')
->select('l');
@ -42,6 +50,15 @@ class LogRepository extends Repository {
}
$query->orderBy('l.createdAt', 'desc');
if ($offset !== null) {
$query->setFirstResult((int)$offset);
}
if ($limit === null) {
$query->setMaxResults(500);
} else {
$query->setMaxResults((int)$limit);
}
return $query->getQuery()->getResult();
}