Skip to content

Commit

Permalink
Merge pull request #1138 from rbayet/feature_1110_massive_num_tracker…
Browse files Browse the repository at this point in the history
…_events_indexing

Resolves #1110 tracker log events indexed by chunk
  • Loading branch information
romainruaud authored Oct 17, 2018
2 parents cc87081 + e99b74f commit 0629085
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/module-elasticsuite-tracker/Cron/IndexLogEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 0629085

Please sign in to comment.