Skip to content

Commit

Permalink
fixed: skipping entities no longer creates additional update batches
Browse files Browse the repository at this point in the history
  • Loading branch information
jeabakker committed Nov 28, 2023
1 parent a5d9fac commit efd9f12
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions classes/ColdTrick/OpenSearch/Di/IndexingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,25 +197,26 @@ public function bulkIndexDocuments(array $params): bool {
};

$index_entities = [];
$batch_size = (int) elgg_extract('batch_size', $options, 25);

/* @var $entities \ElggBatch */
$entities = elgg_get_entities($options);

/* @var $entity \ElggEntity */
foreach ($entities as $entity) {
foreach ($entities as $index => $entity) {
// is this entity prevented from being indexed
$event_params = [
'entity' => $entity,
];

if ((bool) elgg_trigger_event_results('index:entity:prevent', 'opensearch', $event_params, false)) {
$this->markEntityDone($entity);
continue;
} else {
// not prevented so add to the next batch
$index_entities[] = $entity;
}

// not prevented so add to the next batch
$index_entities[] = $entity;
if (count($index_entities) >= 100) {
if (count($index_entities) > 0 && (($index + 1) % $batch_size) === 0) {
// process a batch of allowed entities
$this->processBulkIndexEntities($index_entities);
// reset
Expand Down

0 comments on commit efd9f12

Please sign in to comment.