Skip to content

Commit f052b92

Browse files
author
Bernhard Schmitt
committed
Make progress bar for indexing process disableable
1 parent e99afda commit f052b92

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

Diff for: Classes/Command/GraphIndexCommandController.php

+24-7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ class GraphIndexCommandController extends CommandController
7373
*/
7474
protected $batchSize;
7575

76+
/**
77+
* @Flow\InjectConfiguration(path="indexing.displayProgress")
78+
* @var bool
79+
*/
80+
protected $displayProgress;
81+
7682
/**
7783
* @var array
7884
*/
@@ -95,40 +101,51 @@ public function initializeObject($cause)
95101
* @param boolean $update if TRUE, do not throw away the index at the start. Should *only be used for development*.
96102
* @param string $workspace name of the workspace which should be indexed
97103
* @param string $postfix Index postfix, index with the same postifix will be deleted if exist
104+
* @param bool $displayProgress
98105
* @return void
99106
* @throws ApiException
100-
* @throws \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception
101-
* @throws \Neos\ContentRepository\Exception\NodeTypeNotFoundException
107+
* @throws CRAException
102108
*/
103-
public function buildCommand($limit = null, $update = false, $workspace = null, $postfix = ''): void
109+
public function buildCommand($limit = null, $update = false, $workspace = null, $postfix = '', bool $displayProgress = false): void
104110
{
111+
$displayProgress = $displayProgress || $this->displayProgress;
105112
$this->createNewIndex($postfix);
106113
$this->applyMapping();
107114

108115
$this->logger->log(sprintf('Indexing %snodes ... ', ($limit !== null ? 'the first ' . $limit . ' ' : '')),
109116
LOG_INFO);
110117

111118
$this->outputLine('Initializing content graph...');
112-
$graph = $this->graphService->getContentGraph($this->output);
119+
if ($displayProgress) {
120+
$graph = $this->graphService->getContentGraph($this->output);
121+
} else {
122+
$graph = $this->graphService->getContentGraph();
123+
}
113124

114125
$this->outputLine('Indexing content graph...');
115126
$time = time();
116-
$this->output->progressStart(count($graph->getNodes()));
127+
if ($displayProgress) {
128+
$this->output->progressStart(count($graph->getNodes()));
129+
}
117130
$indexedHierarchyRelations = 0;
118131
$nodesSinceLastFlush = 0;
119132
$this->nodeIndexer->setContentGraph($graph);
120133
foreach ($graph->getNodes() as $node) {
121134
$this->nodeIndexer->indexGraphNode($node);
122135
$nodesSinceLastFlush++;
123136
$indexedHierarchyRelations += count($node->getIncomingHierarchyRelations());
124-
$this->output->progressAdvance();
137+
if ($displayProgress) {
138+
$this->output->progressAdvance();
139+
}
125140
if ($nodesSinceLastFlush >= $this->batchSize) {
126141
$this->nodeIndexer->flush();
127142
$nodesSinceLastFlush = 0;
128143
}
129144
}
130145
$this->output->progressFinish();
131-
$this->nodeIndexer->flush();
146+
if ($displayProgress) {
147+
$this->nodeIndexer->flush();
148+
}
132149
$timeSpent = time() - $time;
133150
$this->logger->log('Done. Indexed ' . count($graph->getNodes()) . ' nodes and ' . $indexedHierarchyRelations . ' edges in ' . $timeSpent . ' s at ' . round(count($graph->getNodes()) / $timeSpent) . ' nodes/s (' . round($indexedHierarchyRelations / $timeSpent) . ' edges/s)',
134151
LOG_INFO);

Diff for: Configuration/Settings.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ Flowpack:
99
ContentGraphAdapter:
1010
indexing:
1111
batchSize: 100
12+
displayProgress: false

0 commit comments

Comments
 (0)