Passed
Push — master ( 1201f0...d3a14d )
by Darko
09:08
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;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         $manticore->truncateRTIndex(Arr::wrap($indexName));
155 155
 
156 156
         $total = Release::count();
157
-        if (! $total) {
157
+        if (!$total) {
158 158
             $this->warn('Releases table is empty. Nothing to do.');
159 159
 
160 160
             return Command::SUCCESS;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             $indexName,
184 184
             $total,
185 185
             $query,
186
-            function ($item) {
186
+            function($item) {
187 187
                 return [
188 188
                     'id' => (string) $item->id,
189 189
                     'name' => (string) ($item->name ?: ''),
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
         $manticore->truncateRTIndex([$indexName]);
209 209
 
210 210
         $total = Predb::count();
211
-        if (! $total) {
211
+        if (!$total) {
212 212
             $this->warn('PreDB table is empty. Nothing to do.');
213 213
 
214 214
             return Command::SUCCESS;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
             $indexName,
223 223
             $total,
224 224
             $query,
225
-            function ($item) {
225
+            function($item) {
226 226
                 return [
227 227
                     'id' => $item->id,
228 228
                     'title' => (string) ($item->title ?? ''),
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         $errorCount = 0;
260 260
 
261 261
         try {
262
-            $query->chunk($chunkSize, function ($items) use ($manticore, $indexName, $transformer, $bar, &$processedCount, &$errorCount) {
262
+            $query->chunk($chunkSize, function($items) use ($manticore, $indexName, $transformer, $bar, &$processedCount, &$errorCount) {
263 263
                 $data = [];
264 264
 
265 265
                 foreach ($items as $item) {
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
                     $bar->advance();
276 276
                 }
277 277
 
278
-                if (! empty($data)) {
278
+                if (!empty($data)) {
279 279
                     $manticore->manticoreSearch->table($indexName)->replaceDocuments($data);
280 280
                 }
281 281
             });
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
     private function elasticReleases(): int
307 307
     {
308 308
         $total = Release::count();
309
-        if (! $total) {
309
+        if (!$total) {
310 310
             $this->warn('Releases table is empty. Nothing to do.');
311 311
 
312 312
             return Command::SUCCESS;
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
             'releases',
338 338
             $total,
339 339
             $query,
340
-            function ($item) {
340
+            function($item) {
341 341
                 $searchName = str_replace(['.', '-'], ' ', $item->searchname ?? '');
342 342
 
343 343
                 return [
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
     private function elasticPredb(): int
361 361
     {
362 362
         $total = Predb::count();
363
-        if (! $total) {
363
+        if (!$total) {
364 364
             $this->warn('PreDB table is empty. Nothing to do.');
365 365
 
366 366
             return Command::SUCCESS;
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
             'predb',
375 375
             $total,
376 376
             $query,
377
-            function ($item) {
377
+            function($item) {
378 378
                 return [
379 379
                     'id' => $item->id,
380 380
                     'title' => $item->title,
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
         $batchSize = min($chunkSize, 1000); // ElasticSearch performs better with smaller bulk sizes
411 411
 
412 412
         try {
413
-            $query->chunk($chunkSize, function ($items) use ($indexName, $transformer, $bar, &$processedCount, &$errorCount, $batchSize) {
413
+            $query->chunk($chunkSize, function($items) use ($indexName, $transformer, $bar, &$processedCount, &$errorCount, $batchSize) {
414 414
                 // Process in smaller batches for ElasticSearch
415 415
                 foreach ($items->chunk($batchSize) as $batch) {
416 416
                     $data = ['body' => []];
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
                         $bar->advance();
439 439
                     }
440 440
 
441
-                    if (! empty($data['body'])) {
441
+                    if (!empty($data['body'])) {
442 442
                         $response = \Elasticsearch::bulk($data);
443 443
 
444 444
                         // Check for errors in bulk response
Please login to merge, or discard this patch.