NNTmux /
newznab-tmux
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace App\Console\Commands; |
||
| 6 | |||
| 7 | use App\Models\Settings; |
||
| 8 | use App\Models\UsenetGroup; |
||
| 9 | use App\Services\AdditionalProcessing\AdditionalProcessingOrchestrator; |
||
|
0 ignored issues
–
show
|
|||
| 10 | use App\Services\Backfill\BackfillService; |
||
| 11 | use App\Services\Binaries\BinariesService; |
||
| 12 | use App\Services\ReleaseProcessingService; |
||
|
0 ignored issues
–
show
The type
App\Services\ReleaseProcessingService was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 13 | use App\Services\NNTP\NNTPService; |
||
| 14 | use Blacklight\Nfo; |
||
| 15 | use Illuminate\Console\Command; |
||
| 16 | use Illuminate\Support\Facades\Log; |
||
| 17 | |||
| 18 | class UpdatePerGroup extends Command |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * The name and signature of the console command. |
||
| 22 | * |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | protected $signature = 'group:update-all {groupId : Group ID to process}'; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * The console command description. |
||
| 29 | * |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | protected $description = 'Do a single group (update_binaries/backFill/update_releases/postprocess)'; |
||
| 33 | |||
| 34 | public function __construct( |
||
| 35 | private readonly ReleaseProcessingService $releaseProcessingService |
||
| 36 | ) { |
||
| 37 | parent::__construct(); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Execute the console command. |
||
| 42 | */ |
||
| 43 | public function handle(): int |
||
| 44 | { |
||
| 45 | $groupId = $this->argument('groupId'); |
||
| 46 | |||
| 47 | if (!is_numeric($groupId)) { |
||
| 48 | $this->error('Group ID must be numeric.'); |
||
| 49 | |||
| 50 | return self::FAILURE; |
||
| 51 | } |
||
| 52 | |||
| 53 | try { |
||
| 54 | $group = UsenetGroup::find($groupId); |
||
| 55 | |||
| 56 | if ($group === null) { |
||
| 57 | $this->error("Group not found with id {$groupId}"); |
||
| 58 | |||
| 59 | return self::FAILURE; |
||
| 60 | } |
||
| 61 | |||
| 62 | $groupMySQL = $group->toArray(); |
||
| 63 | $nntp = $this->getNntp(); |
||
| 64 | $backfillService = new BackfillService(nntp: $nntp); |
||
| 65 | |||
| 66 | // Update the group for new binaries |
||
| 67 | $this->info("Updating binaries for group: {$groupMySQL['name']}"); |
||
| 68 | (new BinariesService())->updateGroup($groupMySQL); |
||
| 69 | |||
| 70 | // BackFill the group with 20k articles |
||
| 71 | $this->info("Backfilling group: {$groupMySQL['name']}"); |
||
| 72 | $backfillService->backfillAllGroups($groupMySQL['name'], 20000, 'normal'); |
||
| 73 | |||
| 74 | // Create releases |
||
| 75 | $this->info("Processing releases for group: {$groupMySQL['name']}"); |
||
| 76 | $this->processReleases((string) $groupId); |
||
| 77 | |||
| 78 | // Post process the releases |
||
| 79 | $this->info("Post-processing additional for group: {$groupMySQL['name']}"); |
||
| 80 | app(AdditionalProcessingOrchestrator::class)->start($groupId); |
||
| 81 | |||
| 82 | $this->info("Processing NFO files for group: {$groupMySQL['name']}"); |
||
| 83 | (new Nfo())->processNfoFiles( |
||
| 84 | $nntp, |
||
| 85 | $groupId, |
||
| 86 | '', |
||
| 87 | (bool) Settings::settingValue('lookupimdb'), |
||
| 88 | (bool) Settings::settingValue('lookuptv') |
||
| 89 | ); |
||
| 90 | |||
| 91 | $this->info("Completed all processing for group: {$groupMySQL['name']}"); |
||
| 92 | |||
| 93 | return self::SUCCESS; |
||
| 94 | } catch (\Throwable $e) { |
||
| 95 | Log::error($e->getTraceAsString()); |
||
| 96 | $this->error($e->getMessage()); |
||
| 97 | |||
| 98 | return self::FAILURE; |
||
| 99 | } |
||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * Create / process releases for a groupID. |
||
| 104 | */ |
||
| 105 | private function processReleases(string $groupID): void |
||
| 106 | { |
||
| 107 | $limit = $this->releaseProcessingService->getReleaseCreationLimit(); |
||
| 108 | |||
| 109 | $this->releaseProcessingService->processIncompleteCollections($groupID); |
||
| 110 | $this->releaseProcessingService->processCollectionSizes($groupID); |
||
| 111 | $this->releaseProcessingService->deleteUnwantedCollections($groupID); |
||
| 112 | |||
| 113 | do { |
||
| 114 | $result = $this->releaseProcessingService->createReleases($groupID); |
||
| 115 | $nzbFilesAdded = $this->releaseProcessingService->createNZBs($groupID); |
||
| 116 | |||
| 117 | $shouldContinue = $result->total() >= $limit || $nzbFilesAdded >= $limit; |
||
| 118 | } while ($shouldContinue); |
||
| 119 | |||
| 120 | $this->releaseProcessingService->deleteCollections($groupID); |
||
| 121 | } |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Get NNTP connection. |
||
| 125 | * |
||
| 126 | * @throws \Exception If unable to connect to usenet |
||
| 127 | */ |
||
| 128 | private function getNntp(): NNTPService |
||
| 129 | { |
||
| 130 | $nntp = new NNTPService(); |
||
| 131 | |||
| 132 | $useAlternate = config('nntmux_nntp.use_alternate_nntp_server') === true; |
||
| 133 | $connected = $useAlternate |
||
| 134 | ? $nntp->doConnect(false, true) |
||
| 135 | : $nntp->doConnect(); |
||
| 136 | |||
| 137 | if ($connected !== true) { |
||
| 138 | throw new \RuntimeException('Unable to connect to usenet.'); |
||
| 139 | } |
||
| 140 | |||
| 141 | return $nntp; |
||
| 142 | } |
||
| 143 | } |
||
| 144 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths