Add offset/limit to logs page
[MAILPOET-3135]
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user