Passed
Push — master ( 62b0d2...788707 )
by Darko
05:54
created
Blacklight/processing/ProcessReleases.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         $this->echoCLI = config('nntmux.echocli');
111 111
         $groupID = '';
112 112
 
113
-        if (! empty($groupName)) {
113
+        if (!empty($groupName)) {
114 114
             $groupInfo = UsenetGroup::getByName($groupName);
115 115
             if ($groupInfo !== null) {
116 116
                 $groupID = $groupInfo['id'];
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
             $this->colorCLI->header('Starting release update process ('.now()->format('Y-m-d H:i:s').')');
122 122
         }
123 123
 
124
-        if (! file_exists(Settings::settingValue('..nzbpath'))) {
124
+        if (!file_exists(Settings::settingValue('..nzbpath'))) {
125 125
             if ($this->echoCLI) {
126 126
                 $this->colorCLI->error('Bad or missing nzb directory - '.Settings::settingValue('..nzbpath'));
127 127
             }
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         $cat = new Categorize();
183 183
         $categorized = $total = 0;
184 184
         $releasesQuery = Release::query()->where(['categories_id' => Category::OTHER_MISC, 'iscategorized' => 0]);
185
-        if (! empty($groupId)) {
185
+        if (!empty($groupId)) {
186 186
             $releasesQuery->where('groups_id', $groupId);
187 187
         }
188 188
         $releases = $releasesQuery->select(['id', 'fromname', 'groups_id', $type])->get();
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
             $this->colorCLI->header('Process Releases -> Attempting to find complete collections.');
219 219
         }
220 220
 
221
-        $where = (! empty($groupID) ? ' AND c.groups_id = '.$groupID.' ' : ' ');
221
+        $where = (!empty($groupID) ? ' AND c.groups_id = '.$groupID.' ' : ' ');
222 222
 
223 223
         $this->processStuckCollections($groupID);
224 224
         $this->collectionFileCheckStage1($groupID);
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         if ($this->echoCLI) {
232 232
             $countQuery = Collection::query()->where('filecheck', self::COLLFC_COMPPART);
233 233
 
234
-            if (! empty($groupID)) {
234
+            if (!empty($groupID)) {
235 235
                 $countQuery->where('groups_id', $groupID);
236 236
             }
237 237
             $count = $countQuery->count('id');
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
             $this->colorCLI->header('Process Releases -> Calculating collection sizes (in bytes).');
259 259
         }
260 260
         // Get the total size in bytes of the collection for collections where filecheck = 2.
261
-        DB::transaction(function () use ($groupID, $startTime) {
261
+        DB::transaction(function() use ($groupID, $startTime) {
262 262
             $checked = DB::update(
263 263
                 sprintf(
264 264
                     '
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 				AND c.filesize = 0 %s',
275 275
                     self::COLLFC_SIZED,
276 276
                     self::COLLFC_COMPPART,
277
-                    (! empty($groupID) ? ' AND c.groups_id = '.$groupID : ' ')
277
+                    (!empty($groupID) ? ' AND c.groups_id = '.$groupID : ' ')
278 278
                 )
279 279
             );
280 280
             if ($checked > 0 && $this->echoCLI) {
@@ -313,16 +313,16 @@  discard block
 block discarded – undo
313 313
 
314 314
             $groupMinimums = UsenetGroup::getGroupByID($grpID['id']);
315 315
             if ($groupMinimums !== null) {
316
-                if (! empty($groupMinimums['minsizetoformrelease']) && $groupMinimums['minsizetoformrelease'] > 0) {
316
+                if (!empty($groupMinimums['minsizetoformrelease']) && $groupMinimums['minsizetoformrelease'] > 0) {
317 317
                     $groupMinSizeSetting = (int) $groupMinimums['minsizetoformrelease'];
318 318
                 }
319
-                if (! empty($groupMinimums['minfilestoformrelease']) && $groupMinimums['minfilestoformrelease'] > 0) {
319
+                if (!empty($groupMinimums['minfilestoformrelease']) && $groupMinimums['minfilestoformrelease'] > 0) {
320 320
                     $groupMinFilesSetting = (int) $groupMinimums['minfilestoformrelease'];
321 321
                 }
322 322
             }
323 323
 
324 324
             if (Collection::query()->where('filecheck', self::COLLFC_SIZED)->where('filesize', '>', 0)->first() !== null) {
325
-                DB::transaction(function () use (
325
+                DB::transaction(function() use (
326 326
                     $groupMinSizeSetting,
327 327
                     $minSizeSetting,
328 328
                     $minSizeDeleted,
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
         $collectionsQuery = Collection::query()
396 396
             ->where('collections.filecheck', self::COLLFC_SIZED)
397 397
             ->where('collections.filesize', '>', 0);
398
-        if (! empty($groupID)) {
398
+        if (!empty($groupID)) {
399 399
             $collectionsQuery->where('collections.groups_id', $groupID);
400 400
         }
401 401
         $collectionsQuery->select(['collections.*', 'usenet_groups.name as gname'])
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
                 $releaseID = Release::insertRelease(
451 451
                     [
452 452
                         'name' => $cleanRelName,
453
-                        'searchname' => ! empty($cleanedName) ? mb_convert_encoding($cleanedName, 'UTF-8', mb_list_encodings()) : $cleanRelName,
453
+                        'searchname' => !empty($cleanedName) ? mb_convert_encoding($cleanedName, 'UTF-8', mb_list_encodings()) : $cleanRelName,
454 454
                         'totalpart' => $collection->totalfiles,
455 455
                         'groups_id' => $collection->groups_id,
456 456
                         'guid' => createGUID(),
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 
467 467
                 if ($releaseID !== null) {
468 468
                     // Update collections table to say we inserted the release.
469
-                    DB::transaction(static function () use ($collection, $releaseID) {
469
+                    DB::transaction(static function() use ($collection, $releaseID) {
470 470
                         Collection::query()->where('id', $collection->id)->update(['filecheck' => self::COLLFC_INSERTED, 'releases_id' => $releaseID]);
471 471
                     }, 10);
472 472
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
                 }
528 528
             } else {
529 529
                 // The release was already in the DB, so delete the collection.
530
-                DB::transaction(static function () use ($collection) {
530
+                DB::transaction(static function() use ($collection) {
531 531
                     Collection::query()->where('collectionhash', $collection->collectionhash)->delete();
532 532
                 }, 10);
533 533
 
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
         }
569 569
 
570 570
         $releasesQuery = Release::query()->with('category.parent')->where('nzbstatus', '=', 0);
571
-        if (! empty($groupID)) {
571
+        if (!empty($groupID)) {
572 572
             $releasesQuery->where('releases.groups_id', $groupID);
573 573
         }
574 574
         $releases = $releasesQuery->select(['id', 'guid', 'name', 'categories_id'])->get();
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
                 ), true);
672 672
         }
673 673
 
674
-        DB::transaction(function () use ($deletedCount, $startTime) {
674
+        DB::transaction(function() use ($deletedCount, $startTime) {
675 675
             $deleted = 0;
676 676
             $deleteQuery = Collection::query()
677 677
                 ->where('dateadded', '<', now()->subHours(Settings::settingValue('..partretentionhours')))
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
             $releases = Release::query()
835 835
                 ->select(['id', 'guid'])
836 836
                 ->where('passwordstatus', '=', Releases::PASSWD_RAR)
837
-                ->orWhereIn('id', function ($query) {
837
+                ->orWhereIn('id', function($query) {
838 838
                     $query->select('releases_id')
839 839
                         ->from('release_files')
840 840
                         ->where('passworded', '=', Releases::PASSWD_RAR);
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
             foreach ($genrelist as $genre) {
894 894
                 $musicInfoQuery = MusicInfo::query()->where('genre_id', (int) $genre['id'])->select(['id']);
895 895
                 $releases = Release::query()
896
-                    ->joinSub($musicInfoQuery, 'mi', function ($join) {
896
+                    ->joinSub($musicInfoQuery, 'mi', function($join) {
897 897
                         $join->on('releases.musicinfo_id', '=', 'mi.id');
898 898
                     })
899 899
                     ->select(['releases.id', 'releases.guid'])
@@ -979,18 +979,18 @@  discard block
 block discarded – undo
979 979
      */
980 980
     private function collectionFileCheckStage1(int $groupID): void
981 981
     {
982
-        DB::transaction(static function () use ($groupID) {
982
+        DB::transaction(static function() use ($groupID) {
983 983
             $collectionsCheck = Collection::query()->select(['collections.id'])
984 984
                 ->join('binaries', 'binaries.collections_id', '=', 'collections.id')
985 985
                 ->where('collections.totalfiles', '>', 0)
986 986
                 ->where('collections.filecheck', '=', self::COLLFC_DEFAULT);
987
-            if (! empty($groupID)) {
987
+            if (!empty($groupID)) {
988 988
                 $collectionsCheck->where('collections.groups_id', $groupID);
989 989
             }
990 990
             $collectionsCheck->groupBy('binaries.collections_id', 'collections.totalfiles', 'collections.id')
991 991
                 ->havingRaw('COUNT(binaries.id) IN (collections.totalfiles, collections.totalfiles+1)');
992 992
 
993
-            Collection::query()->joinSub($collectionsCheck, 'r', function ($join) {
993
+            Collection::query()->joinSub($collectionsCheck, 'r', function($join) {
994 994
                 $join->on('collections.id', '=', 'r.id');
995 995
             })->update(['collections.filecheck' => self::COLLFC_COMPCOLL]);
996 996
         }, 10);
@@ -1011,25 +1011,25 @@  discard block
 block discarded – undo
1011 1011
      */
1012 1012
     private function collectionFileCheckStage2(int $groupID): void
1013 1013
     {
1014
-        DB::transaction(static function () use ($groupID) {
1014
+        DB::transaction(static function() use ($groupID) {
1015 1015
             $collectionsCheck = Collection::query()->select(['collections.id'])
1016 1016
                 ->join('binaries', 'binaries.collections_id', '=', 'collections.id')
1017 1017
                 ->where('binaries.filenumber', '=', 0)
1018 1018
                 ->where('collections.totalfiles', '>', 0)
1019 1019
                 ->where('collections.filecheck', '=', self::COLLFC_COMPCOLL);
1020
-            if (! empty($groupID)) {
1020
+            if (!empty($groupID)) {
1021 1021
                 $collectionsCheck->where('collections.groups_id', $groupID);
1022 1022
             }
1023 1023
             $collectionsCheck->groupBy('collections.id');
1024 1024
 
1025
-            Collection::query()->joinSub($collectionsCheck, 'r', function ($join) {
1025
+            Collection::query()->joinSub($collectionsCheck, 'r', function($join) {
1026 1026
                 $join->on('collections.id', '=', 'r.id');
1027 1027
             })->update(['collections.filecheck' => self::COLLFC_ZEROPART]);
1028 1028
         }, 10);
1029 1029
 
1030
-        DB::transaction(static function () use ($groupID) {
1030
+        DB::transaction(static function() use ($groupID) {
1031 1031
             $collectionQuery = Collection::query()->where('filecheck', '=', self::COLLFC_COMPCOLL);
1032
-            if (! empty($groupID)) {
1032
+            if (!empty($groupID)) {
1033 1033
                 $collectionQuery->where('groups_id', $groupID);
1034 1034
             }
1035 1035
             $collectionQuery->update(['filecheck' => self::COLLFC_TEMPCOMP]);
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
      */
1048 1048
     private function collectionFileCheckStage3(string $where): void
1049 1049
     {
1050
-        DB::transaction(static function () use ($where) {
1050
+        DB::transaction(static function() use ($where) {
1051 1051
             DB::update(
1052 1052
                 sprintf(
1053 1053
                     '
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
             );
1072 1072
         }, 10);
1073 1073
 
1074
-        DB::transaction(static function () use ($where) {
1074
+        DB::transaction(static function() use ($where) {
1075 1075
             DB::update(
1076 1076
                 sprintf(
1077 1077
                     '
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
      */
1109 1109
     private function collectionFileCheckStage4(string &$where): void
1110 1110
     {
1111
-        DB::transaction(static function () use ($where) {
1111
+        DB::transaction(static function() use ($where) {
1112 1112
             DB::update(
1113 1113
                 sprintf(
1114 1114
                     '
@@ -1138,9 +1138,9 @@  discard block
 block discarded – undo
1138 1138
      */
1139 1139
     private function collectionFileCheckStage5(int $groupId): void
1140 1140
     {
1141
-        DB::transaction(static function () use ($groupId) {
1141
+        DB::transaction(static function() use ($groupId) {
1142 1142
             $collectionQuery = Collection::query()->whereIn('filecheck', [self::COLLFC_TEMPCOMP, self::COLLFC_ZEROPART]);
1143
-            if (! empty($groupId)) {
1143
+            if (!empty($groupId)) {
1144 1144
                 $collectionQuery->where('groups_id', $groupId);
1145 1145
             }
1146 1146
             $collectionQuery->update(['filecheck' => self::COLLFC_COMPCOLL]);
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
      */
1159 1159
     private function collectionFileCheckStage6(string &$where): void
1160 1160
     {
1161
-        DB::transaction(function () use ($where) {
1161
+        DB::transaction(function() use ($where) {
1162 1162
             DB::update(
1163 1163
                 sprintf(
1164 1164
                     "
@@ -1188,10 +1188,10 @@  discard block
 block discarded – undo
1188 1188
     {
1189 1189
         $lastRun = Settings::settingValue('indexer.processing.last_run_time');
1190 1190
 
1191
-        DB::transaction(function () use ($groupID, $lastRun) {
1191
+        DB::transaction(function() use ($groupID, $lastRun) {
1192 1192
             $objQuery = Collection::query()
1193 1193
                 ->where('added', '<', Carbon::createFromFormat('Y-m-d H:i:s', $lastRun)->subHours($this->collectionTimeout));
1194
-            if (! empty($groupID)) {
1194
+            if (!empty($groupID)) {
1195 1195
                 $objQuery->where('groups_id', $groupID);
1196 1196
             }
1197 1197
             $obj = $objQuery->delete();
Please login to merge, or discard this patch.