Passed
Push — master ( 270f36...5637d3 )
by Darko
07:40
created
app/Console/Commands/NntmuxPopulateSearchIndexes.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             $engine = $this->getSelectedEngine();
54 54
             $index = $this->getSelectedIndex();
55 55
 
56
-            if (! $engine || ! $index) {
56
+            if (!$engine || !$index) {
57 57
                 $this->error('You must specify both an engine (--manticore or --elastic) and an index (--releases or --predb).');
58 58
                 $this->info('Use --help to see all available options.');
59 59
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     {
128 128
         $methodName = "{$engine}".ucfirst($index);
129 129
 
130
-        if (! method_exists($this, $methodName)) {
130
+        if (!method_exists($this, $methodName)) {
131 131
             $this->error("Method {$methodName} not implemented.");
132 132
 
133 133
             return Command::FAILURE;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         $manticore->truncateRTIndex(Arr::wrap($indexName));
158 158
 
159 159
         $total = Release::count();
160
-        if (! $total) {
160
+        if (!$total) {
161 161
             $this->warn('Releases table is empty. Nothing to do.');
162 162
 
163 163
             return Command::SUCCESS;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
             $indexName,
187 187
             $total,
188 188
             $query,
189
-            function ($item) {
189
+            function($item) {
190 190
                 return [
191 191
                     'id' => $item->id,
192 192
                     'name' => (string) ($item->name ?? ''),
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
         $manticore->truncateRTIndex([$indexName]);
212 212
 
213 213
         $total = Predb::count();
214
-        if (! $total) {
214
+        if (!$total) {
215 215
             $this->warn('PreDB table is empty. Nothing to do.');
216 216
 
217 217
             return Command::SUCCESS;
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
             $indexName,
226 226
             $total,
227 227
             $query,
228
-            function ($item) {
228
+            function($item) {
229 229
                 return [
230 230
                     'id' => $item->id,
231 231
                     'title' => (string) ($item->title ?? ''),
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
         $errorCount = 0;
263 263
 
264 264
         try {
265
-            $query->chunk($chunkSize, function ($items) use ($manticore, $indexName, $transformer, $bar, &$processedCount, &$errorCount) {
265
+            $query->chunk($chunkSize, function($items) use ($manticore, $indexName, $transformer, $bar, &$processedCount, &$errorCount) {
266 266
                 $data = [];
267 267
 
268 268
                 foreach ($items as $item) {
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
                     $bar->advance();
279 279
                 }
280 280
 
281
-                if (! empty($data)) {
281
+                if (!empty($data)) {
282 282
                     $manticore->manticoreSearch->table($indexName)->replaceDocuments($data);
283 283
                 }
284 284
             });
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
     private function elasticReleases(): int
310 310
     {
311 311
         $total = Release::count();
312
-        if (! $total) {
312
+        if (!$total) {
313 313
             $this->warn('Releases table is empty. Nothing to do.');
314 314
 
315 315
             return Command::SUCCESS;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
             'releases',
341 341
             $total,
342 342
             $query,
343
-            function ($item) {
343
+            function($item) {
344 344
                 $searchName = str_replace(['.', '-'], ' ', $item->searchname ?? '');
345 345
 
346 346
                 return [
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
     private function elasticPredb(): int
364 364
     {
365 365
         $total = Predb::count();
366
-        if (! $total) {
366
+        if (!$total) {
367 367
             $this->warn('PreDB table is empty. Nothing to do.');
368 368
 
369 369
             return Command::SUCCESS;
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
             'predb',
378 378
             $total,
379 379
             $query,
380
-            function ($item) {
380
+            function($item) {
381 381
                 return [
382 382
                     'id' => $item->id,
383 383
                     'title' => $item->title,
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
         $batchSize = min($chunkSize, 1000); // ElasticSearch performs better with smaller bulk sizes
414 414
 
415 415
         try {
416
-            $query->chunk($chunkSize, function ($items) use ($indexName, $transformer, $bar, &$processedCount, &$errorCount, $batchSize) {
416
+            $query->chunk($chunkSize, function($items) use ($indexName, $transformer, $bar, &$processedCount, &$errorCount, $batchSize) {
417 417
                 // Process in smaller batches for ElasticSearch
418 418
                 foreach ($items->chunk($batchSize) as $batch) {
419 419
                     $data = ['body' => []];
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
                         $bar->advance();
442 442
                     }
443 443
 
444
-                    if (! empty($data['body'])) {
444
+                    if (!empty($data['body'])) {
445 445
                         $response = \Elasticsearch::bulk($data);
446 446
 
447 447
                         // Check for errors in bulk response
Please login to merge, or discard this patch.