diff --git a/src/module-elasticsuite-tracker/Cron/IndexLogEvent.php b/src/module-elasticsuite-tracker/Cron/IndexLogEvent.php index 309aba328..4f98a97ed 100644 --- a/src/module-elasticsuite-tracker/Cron/IndexLogEvent.php +++ b/src/module-elasticsuite-tracker/Cron/IndexLogEvent.php @@ -38,21 +38,29 @@ class IndexLogEvent */ private $sessionIndex; + /** + * @var integer + */ + private $chunkSize; + /** * Constructor. * * @param \Smile\ElasticsuiteTracker\Api\EventQueueInterface $eventQueue Pending events queue. * @param \Smile\ElasticsuiteTracker\Api\SessionIndexInterface $eventIndex Event index. * @param \Smile\ElasticsuiteTracker\Api\EventIndexInterface $sessionIndex Session index. + * @param integer $chunkSize Size of the chunk of events to index. */ public function __construct( \Smile\ElasticsuiteTracker\Api\EventQueueInterface $eventQueue, \Smile\ElasticsuiteTracker\Api\EventIndexInterface $eventIndex, - \Smile\ElasticsuiteTracker\Api\SessionIndexInterface $sessionIndex + \Smile\ElasticsuiteTracker\Api\SessionIndexInterface $sessionIndex, + $chunkSize = 10000 ) { $this->eventQueue = $eventQueue; $this->eventIndex = $eventIndex; $this->sessionIndex = $sessionIndex; + $this->chunkSize = $chunkSize; } /** @@ -62,7 +70,7 @@ public function __construct( */ public function execute() { - $events = $this->eventQueue->getEvents(); + $events = $this->eventQueue->getEvents($this->chunkSize); if (!empty($events)) { $this->eventIndex->indexEvents($events); $this->sessionIndex->indexEvents($events); diff --git a/src/module-elasticsuite-tracker/Model/ResourceModel/EventQueue.php b/src/module-elasticsuite-tracker/Model/ResourceModel/EventQueue.php index 365835044..7d938caf7 100644 --- a/src/module-elasticsuite-tracker/Model/ResourceModel/EventQueue.php +++ b/src/module-elasticsuite-tracker/Model/ResourceModel/EventQueue.php @@ -66,7 +66,7 @@ public function saveEvent($eventData) * * @param integer $limit Max number of events to be retrieved. * - * @return void + * @return array */ public function getEvents($limit = null) {