fix last viewed 2

This commit is contained in:
yuri
2018-11-13 17:14:22 +02:00
parent 0be7bbd57e
commit 614900443d
+8 -3
View File
@@ -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