Skip to content

Commit

Permalink
refactor: Move Commands around
Browse files Browse the repository at this point in the history
Update readme.md
  • Loading branch information
octfx committed Jan 2, 2024
1 parent 41d751f commit bfb0f6e
Show file tree
Hide file tree
Showing 29 changed files with 108 additions and 380 deletions.
56 changes: 0 additions & 56 deletions app/Console/Commands/CopyTranslationData.php

This file was deleted.

40 changes: 0 additions & 40 deletions app/Console/Commands/FixChangelogNamespaces.php

This file was deleted.

5 changes: 4 additions & 1 deletion app/Console/Commands/PopulateData.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ public function handle()
$this->bar->advance();

if (!$this->option('skipCommLinks')) {
$this->info('Downloading and importing all missing Comm-Links.');
Artisan::call('comm-links:schedule');
}
$this->bar->advance();

if (!$this->option('skipGalactapedia')) {
$this->info('Downloading and importing all Galactapedia articles.');
Artisan::call('galactapedia:import-categories');
Artisan::call('galactapedia:import-articles');
Artisan::call('galactapedia:import-properties');
Expand All @@ -51,13 +53,14 @@ public function handle()
$this->bar->advance();

if (!$this->option('skipStarmap')) {
$this->info('Downloading and importing starmap.');
Artisan::call('starmap:download --import');
}
$this->bar->advance();

if (!$this->option('skipScUnpacked')) {
$this->info('Importing all Star Citizen Items.');
Artisan::call('sc:import-items');
Artisan::call('sc:import-shops');
}
$this->bar->finish();

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/Rsi/CommLink/CommLinkSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ public function handle(): int
]
);

return 0;
return Command::SUCCESS;
}
}
15 changes: 6 additions & 9 deletions app/Console/Commands/Rsi/CommLink/Download/DownloadCommLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(Dispatcher $dispatcher)
*/
public function handle(): int
{
$minId = collect($this->argument('id'))->filter(
collect($this->argument('id'))->filter(
static function ($id) {
return is_numeric($id);
}
Expand All @@ -85,27 +85,24 @@ function (int $id) {
$this->dispatcher->dispatch(new DownloadCommLinkJob($id, $skipExisting));
$this->advanceBar();
}
)
->min();
);

$this->finishBar();

if ($this->option('import') === true) {
$this->dispatchImportJob((int)$minId);
$this->dispatchImportJob();
}

return 0;
return CommLinkCommand::SUCCESS;
}

/**
* Import jobs to run after downloading comm link files
*
* @param int $minId
*/
private function dispatchImportJob(int $minId): void
private function dispatchImportJob(): void
{
$this->info("\nImporting Comm-Links");
$this->dispatcher->dispatch(new ImportCommLinks($minId));
$this->dispatcher->dispatch(new ImportCommLinks(30));
$this->dispatcher->dispatch(new CreateImageMetadata());
$this->dispatcher->dispatch(new CreateImageHashes());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Console\Commands\Rsi\CommLink\Download\Image;
namespace App\Console\Commands\Rsi\CommLink\Download;

use App\Jobs\Rsi\CommLink\Download\Image\DownloadCommLinkImage;
use App\Jobs\Rsi\CommLink\Download\Image\DownloadCommLinkImages as DownloadCommLinkImagesJob;
Expand Down Expand Up @@ -36,8 +36,8 @@ class DownloadCommLinkImages extends Command
*/
public function handle(): int
{
dispatch(new DownloadCommLinkImagesJob());
DownloadCommLinkImagesJob::dispatch();

return 0;
return Command::SUCCESS;
}
}
38 changes: 0 additions & 38 deletions app/Console/Commands/Rsi/CommLink/Download/DownloadCommLinks.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ public function handle(): int
]
)->onQueue('redownload_comm_links')->dispatch($skip);

return 0;
return Command::SUCCESS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ComputeSimilarImageIds extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
Image::query()
->whereNull('base_image_id')
Expand All @@ -45,5 +45,7 @@ public function handle()
\App\Jobs\Rsi\CommLink\Image\ComputeSimilarImageIds::dispatch($image)->onQueue('comm_link_images');
});
});

return Command::SUCCESS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function (Image $image) {

$this->finishBar();

return 0;
return QueueCommand::SUCCESS;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function handle(): int
function (Collection $images) {
$images->each(
function (Image $image) {
dispatch(new CreateImageMetadatum($image));
CreateImageMetadatum::dispatch($image);
$this->advanceBar();
}
);
Expand All @@ -54,6 +54,6 @@ function (Image $image) {

$this->finishBar();

return 0;
return QueueCommand::SUCCESS;
}
}
21 changes: 2 additions & 19 deletions app/Console/Commands/Rsi/CommLink/Image/SyncImageIds.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,6 @@ class SyncImageIds extends CommLinkCommand
*/
protected $description = 'Re-Parse all local Comm-Links and sync the images';

/**
* @var Dispatcher
*/
private Dispatcher $dispatcher;

/**
* Create a new command instance.
*
* @param Dispatcher $dispatcher
*/
public function __construct(Dispatcher $dispatcher)
{
parent::__construct();

$this->dispatcher = $dispatcher;
}

/**
* Execute the console command.
*
Expand All @@ -53,8 +36,8 @@ public function handle(): int

$this->info("Starting at Comm-Link ID {$offset}");

$this->dispatcher->dispatch(new \App\Jobs\Rsi\CommLink\SyncImageIds($offset));
\App\Jobs\Rsi\CommLink\SyncImageIds::dispatch($offset);

return 0;
return CommLinkCommand::SUCCESS;
}
}
68 changes: 0 additions & 68 deletions app/Console/Commands/Rsi/CommLink/Import/ImportCommLinks.php

This file was deleted.

Loading

0 comments on commit bfb0f6e

Please sign in to comment.