Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions src/Service/AnalyzeBatchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,10 @@ public function getAnalysisStatus(array $analyzer_ids, array $entity_bundles): a
* Batch context.
*/
public function processBatch(array $entities, array $analyzer_ids, bool $force_refresh, int $total_entities, array &$context): void {
if (!isset($context['sandbox']['total_entities'])) {
$context['sandbox']['total_entities'] = $total_entities;
$context['results']['processed'] = 0;
$context['results']['failed'] = 0;
$context['results']['rate_limited'] = 0;
$context['results']['errors'] = [];
}
$context['results']['processed'] = $context['results']['processed'] ?? 0;
$context['results']['failed'] = $context['results']['failed'] ?? 0;
$context['results']['rate_limited'] = $context['results']['rate_limited'] ?? 0;
$context['results']['errors'] = $context['results']['errors'] ?? [];

// Build analyzer instances.
$all_analyzers = [];
Expand Down Expand Up @@ -317,15 +314,12 @@ public function processBatch(array $entities, array $analyzer_ids, bool $force_r
$done = $context['results']['processed'] + $context['results']['failed'];
$context['message'] = $this->t('Processed @current of @max entities...', [
'@current' => $done,
'@max' => $context['sandbox']['total_entities'],
'@max' => $total_entities,
])->render();

if ($context['sandbox']['total_entities'] > 0) {
$context['finished'] = $done / $context['sandbox']['total_entities'];
}
else {
$context['finished'] = 1;
}
// Each chunk is a separate batch operation, so mark it complete.
// Drupal advances to the next operation when finished >= 1.
$context['finished'] = 1;
}

/**
Expand Down Expand Up @@ -429,7 +423,7 @@ private function getFullyAnalyzedEntityIds(array $analyzer_ids, string $entity_t
}
}
catch (\Exception) {
// Entity type may lack a view_builder skip it.
// Entity type may lack a view_builder, skip it.
}
}
// Clear static entity cache to keep memory flat.
Expand Down