fix last viewed 2
This commit is contained in:
@@ -66,15 +66,20 @@ class LastViewed extends \Espo\Core\Services\Base
|
||||
'groupBy' => ['targetId', 'targetType']
|
||||
];
|
||||
|
||||
$collection = $repository->limit($offset, $maxSize)->find($selectParams);
|
||||
|
||||
$total = $repository->count($selectParams);
|
||||
$collection = $repository->limit($offset, $params['maxSize'] + 1)->find($selectParams);
|
||||
|
||||
foreach ($collection as $i => $entity) {
|
||||
$actionHistoryRecordService->loadParentNameFields($entity);
|
||||
$entity->set('id', \Espo\Core\Utils\Util::generateId());
|
||||
}
|
||||
|
||||
if ($maxSize && count($collection) > $maxSize) {
|
||||
$total = -1;
|
||||
unset($collection[count($collection) - 1]);
|
||||
} else {
|
||||
$total = -2;
|
||||
}
|
||||
|
||||
return (object) [
|
||||
'total' => $total,
|
||||
'collection' => $collection
|
||||
|
||||
Reference in New Issue
Block a user