From bfb0f6efda0e22da18f3fd8bfb360d7ebff1c3b9 Mon Sep 17 00:00:00 2001
From: "H. C. Kruse"
Date: Tue, 2 Jan 2024 13:51:00 +0100
Subject: [PATCH] refactor: Move Commands around
Update readme.md
---
app/Console/Commands/CopyTranslationData.php | 56 ---------------
.../Commands/FixChangelogNamespaces.php | 40 -----------
app/Console/Commands/PopulateData.php | 5 +-
.../Rsi/CommLink/CommLinkSchedule.php | 2 +-
.../CommLink/Download/DownloadCommLink.php | 15 ++--
.../{Image => }/DownloadCommLinkImages.php | 6 +-
.../CommLink/Download/DownloadCommLinks.php | 38 -----------
.../CommLink/Download/ReDownloadCommLinks.php | 2 +-
.../CommLink/Image/ComputeSimilarImageIds.php | 4 +-
.../Rsi/CommLink/Image/CreateImageHashes.php | 2 +-
.../CommLink/Image/CreateImageMetadata.php | 4 +-
.../Rsi/CommLink/Image/SyncImageIds.php | 21 +-----
.../Rsi/CommLink/Import/ImportCommLinks.php | 68 -------------------
.../CommLink/{Import => }/ImportCommLink.php | 22 ++++--
.../{Translate => }/TranslateCommLinks.php | 6 +-
.../CommLink/Wiki/CreateCommLinkWikiPages.php | 4 +-
.../CreateCommLinkWikiTranslationPages.php | 2 +-
.../{Download => }/DownloadShipMatrix.php | 2 +-
.../{Import => }/ImportShipMatrix.php | 2 +-
.../{Download => }/DownloadStarmap.php | 2 +-
.../Starmap/{Import => }/ImportStarmap.php | 2 +-
.../{Translate => }/TranslateSystems.php | 2 +-
.../Stat/{Download => }/DownloadStats.php | 2 +-
.../Stat/{Import => }/ImportStats.php | 2 +-
app/Console/Kernel.php | 49 ++++++-------
readme.md | 34 +++++++---
.../Download/DownloadCommLinksTest.php | 28 --------
.../CommLink/Import/ImportCommLinkTest.php | 13 +++-
.../CommLink/Import/ImportCommLinksTest.php | 53 ---------------
29 files changed, 108 insertions(+), 380 deletions(-)
delete mode 100644 app/Console/Commands/CopyTranslationData.php
delete mode 100644 app/Console/Commands/FixChangelogNamespaces.php
rename app/Console/Commands/Rsi/CommLink/Download/{Image => }/DownloadCommLinkImages.php (86%)
delete mode 100644 app/Console/Commands/Rsi/CommLink/Download/DownloadCommLinks.php
delete mode 100644 app/Console/Commands/Rsi/CommLink/Import/ImportCommLinks.php
rename app/Console/Commands/Rsi/CommLink/{Import => }/ImportCommLink.php (65%)
rename app/Console/Commands/Rsi/CommLink/{Translate => }/TranslateCommLinks.php (85%)
rename app/Console/Commands/StarCitizen/ShipMatrix/{Download => }/DownloadShipMatrix.php (96%)
rename app/Console/Commands/StarCitizen/ShipMatrix/{Import => }/ImportShipMatrix.php (94%)
rename app/Console/Commands/StarCitizen/Starmap/{Download => }/DownloadStarmap.php (97%)
rename app/Console/Commands/StarCitizen/Starmap/{Import => }/ImportStarmap.php (91%)
rename app/Console/Commands/StarCitizen/Starmap/{Translate => }/TranslateSystems.php (92%)
rename app/Console/Commands/StarCitizen/Stat/{Download => }/DownloadStats.php (96%)
rename app/Console/Commands/StarCitizen/Stat/{Import => }/ImportStats.php (95%)
delete mode 100644 tests/Feature/Console/Commands/CommLink/Download/DownloadCommLinksTest.php
delete mode 100644 tests/Feature/Console/Commands/CommLink/Import/ImportCommLinksTest.php
diff --git a/app/Console/Commands/CopyTranslationData.php b/app/Console/Commands/CopyTranslationData.php
deleted file mode 100644
index 4da15f3ae..000000000
--- a/app/Console/Commands/CopyTranslationData.php
+++ /dev/null
@@ -1,56 +0,0 @@
-insertUsing(
- ['locale_code', 'item_uuid', 'translation', 'updated_at', 'created_at'],
- function (Builder $query) {
- $query->select([
- 'star_citizen_unpacked_item_translations.locale_code',
- 'star_citizen_unpacked_item_translations.item_uuid',
- 'star_citizen_unpacked_item_translations.translation',
- 'star_citizen_unpacked_item_translations.updated_at',
- 'star_citizen_unpacked_item_translations.created_at'
- ])
- ->from('star_citizen_unpacked_item_translations')
- ->where('star_citizen_unpacked_item_translations.locale_code', 'de_DE')
- ->leftJoin(
- 'sc_item_translations',
- 'sc_item_translations.locale_code',
- '=',
- 'star_citizen_unpacked_item_translations.locale_code'
- )
- ->whereNull('sc_item_translations.item_uuid');
- }
- );
-
- return Command::SUCCESS;
- }
-}
diff --git a/app/Console/Commands/FixChangelogNamespaces.php b/app/Console/Commands/FixChangelogNamespaces.php
deleted file mode 100644
index c7fc6b3c3..000000000
--- a/app/Console/Commands/FixChangelogNamespaces.php
+++ /dev/null
@@ -1,40 +0,0 @@
-update([
- 'changelog_type' => DB::raw('REPLACE(changelog_type, "\\Api\\StarCitizen", "\\StarCitizen")'),
- ]);
-
- return 0;
- }
-}
diff --git a/app/Console/Commands/PopulateData.php b/app/Console/Commands/PopulateData.php
index 194b43899..1ec601cdd 100644
--- a/app/Console/Commands/PopulateData.php
+++ b/app/Console/Commands/PopulateData.php
@@ -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');
@@ -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();
diff --git a/app/Console/Commands/Rsi/CommLink/CommLinkSchedule.php b/app/Console/Commands/Rsi/CommLink/CommLinkSchedule.php
index ccfb9ac42..bd6baf34d 100644
--- a/app/Console/Commands/Rsi/CommLink/CommLinkSchedule.php
+++ b/app/Console/Commands/Rsi/CommLink/CommLinkSchedule.php
@@ -39,6 +39,6 @@ public function handle(): int
]
);
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/app/Console/Commands/Rsi/CommLink/Download/DownloadCommLink.php b/app/Console/Commands/Rsi/CommLink/Download/DownloadCommLink.php
index 162f8b39b..b9d10a788 100644
--- a/app/Console/Commands/Rsi/CommLink/Download/DownloadCommLink.php
+++ b/app/Console/Commands/Rsi/CommLink/Download/DownloadCommLink.php
@@ -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);
}
@@ -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());
}
diff --git a/app/Console/Commands/Rsi/CommLink/Download/Image/DownloadCommLinkImages.php b/app/Console/Commands/Rsi/CommLink/Download/DownloadCommLinkImages.php
similarity index 86%
rename from app/Console/Commands/Rsi/CommLink/Download/Image/DownloadCommLinkImages.php
rename to app/Console/Commands/Rsi/CommLink/Download/DownloadCommLinkImages.php
index b0cdf7e42..9d9dc7169 100644
--- a/app/Console/Commands/Rsi/CommLink/Download/Image/DownloadCommLinkImages.php
+++ b/app/Console/Commands/Rsi/CommLink/Download/DownloadCommLinkImages.php
@@ -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;
@@ -36,8 +36,8 @@ class DownloadCommLinkImages extends Command
*/
public function handle(): int
{
- dispatch(new DownloadCommLinkImagesJob());
+ DownloadCommLinkImagesJob::dispatch();
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/app/Console/Commands/Rsi/CommLink/Download/DownloadCommLinks.php b/app/Console/Commands/Rsi/CommLink/Download/DownloadCommLinks.php
deleted file mode 100644
index da0fd747d..000000000
--- a/app/Console/Commands/Rsi/CommLink/Download/DownloadCommLinks.php
+++ /dev/null
@@ -1,38 +0,0 @@
-info('Downloading all Comm-Links');
- dispatch(new DownloadMissingCommLinks());
-
- return 0;
- }
-}
diff --git a/app/Console/Commands/Rsi/CommLink/Download/ReDownloadCommLinks.php b/app/Console/Commands/Rsi/CommLink/Download/ReDownloadCommLinks.php
index a5ecda9f5..e8ad9ac8a 100644
--- a/app/Console/Commands/Rsi/CommLink/Download/ReDownloadCommLinks.php
+++ b/app/Console/Commands/Rsi/CommLink/Download/ReDownloadCommLinks.php
@@ -48,6 +48,6 @@ public function handle(): int
]
)->onQueue('redownload_comm_links')->dispatch($skip);
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/app/Console/Commands/Rsi/CommLink/Image/ComputeSimilarImageIds.php b/app/Console/Commands/Rsi/CommLink/Image/ComputeSimilarImageIds.php
index 89fa3fe1f..62cab673f 100644
--- a/app/Console/Commands/Rsi/CommLink/Image/ComputeSimilarImageIds.php
+++ b/app/Console/Commands/Rsi/CommLink/Image/ComputeSimilarImageIds.php
@@ -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')
@@ -45,5 +45,7 @@ public function handle()
\App\Jobs\Rsi\CommLink\Image\ComputeSimilarImageIds::dispatch($image)->onQueue('comm_link_images');
});
});
+
+ return Command::SUCCESS;
}
}
diff --git a/app/Console/Commands/Rsi/CommLink/Image/CreateImageHashes.php b/app/Console/Commands/Rsi/CommLink/Image/CreateImageHashes.php
index d75e14ea8..0139d8fa9 100644
--- a/app/Console/Commands/Rsi/CommLink/Image/CreateImageHashes.php
+++ b/app/Console/Commands/Rsi/CommLink/Image/CreateImageHashes.php
@@ -53,7 +53,7 @@ function (Image $image) {
$this->finishBar();
- return 0;
+ return QueueCommand::SUCCESS;
}
/**
diff --git a/app/Console/Commands/Rsi/CommLink/Image/CreateImageMetadata.php b/app/Console/Commands/Rsi/CommLink/Image/CreateImageMetadata.php
index 0042da777..ee853e44c 100644
--- a/app/Console/Commands/Rsi/CommLink/Image/CreateImageMetadata.php
+++ b/app/Console/Commands/Rsi/CommLink/Image/CreateImageMetadata.php
@@ -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();
}
);
@@ -54,6 +54,6 @@ function (Image $image) {
$this->finishBar();
- return 0;
+ return QueueCommand::SUCCESS;
}
}
diff --git a/app/Console/Commands/Rsi/CommLink/Image/SyncImageIds.php b/app/Console/Commands/Rsi/CommLink/Image/SyncImageIds.php
index 8091ad48a..0e9a32679 100644
--- a/app/Console/Commands/Rsi/CommLink/Image/SyncImageIds.php
+++ b/app/Console/Commands/Rsi/CommLink/Image/SyncImageIds.php
@@ -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.
*
@@ -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;
}
}
diff --git a/app/Console/Commands/Rsi/CommLink/Import/ImportCommLinks.php b/app/Console/Commands/Rsi/CommLink/Import/ImportCommLinks.php
deleted file mode 100644
index 2cc915ac5..000000000
--- a/app/Console/Commands/Rsi/CommLink/Import/ImportCommLinks.php
+++ /dev/null
@@ -1,68 +0,0 @@
-dispatcher = $dispatcher;
- }
-
- /**
- * Execute the console command.
- *
- * @return int
- */
- public function handle(): int
- {
- $this->info('Dispatching Comm-Link Import');
-
- $offset = (int)$this->argument('modifiedTime');
-
- if ($offset > 0) {
- $this->info("Including Comm-Links that were created in the last '{$offset}' minutes");
- } elseif ($offset === -1) {
- $this->info('Including all Comm-Links');
- }
-
- $this->dispatcher->dispatch(new ImportCommLinkJobs($offset));
-
- return 0;
- }
-}
diff --git a/app/Console/Commands/Rsi/CommLink/Import/ImportCommLink.php b/app/Console/Commands/Rsi/CommLink/ImportCommLink.php
similarity index 65%
rename from app/Console/Commands/Rsi/CommLink/Import/ImportCommLink.php
rename to app/Console/Commands/Rsi/CommLink/ImportCommLink.php
index 914ea158f..52dbd2d79 100644
--- a/app/Console/Commands/Rsi/CommLink/Import/ImportCommLink.php
+++ b/app/Console/Commands/Rsi/CommLink/ImportCommLink.php
@@ -2,9 +2,10 @@
declare(strict_types=1);
-namespace App\Console\Commands\Rsi\CommLink\Import;
+namespace App\Console\Commands\Rsi\CommLink;
use App\Jobs\Rsi\CommLink\Import\ImportCommLink as ImportCommLinkJob;
+use App\Jobs\Rsi\CommLink\Import\ImportCommLinks as ImportCommLinksJob;
use App\Models\Rsi\CommLink\CommLink;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\ModelNotFoundException;
@@ -19,14 +20,14 @@ class ImportCommLink extends Command
*
* @var string
*/
- protected $signature = 'comm-links:import {id : Comm-Link ID starting at 12663}';
+ protected $signature = 'comm-links:import {id? : Comm-Link ID starting at 12663} {--all : Import all downloaded Comm-Links}';
/**
* The console command description.
*
* @var string
*/
- protected $description = 'Re-Import a single downloaded Comm-Link';
+ protected $description = 'Import a single or all Comm-Links. Downloads single Comm-Link if missing.';
/**
* Execute the console command.
@@ -35,6 +36,17 @@ class ImportCommLink extends Command
*/
public function handle(): int
{
+ if ($this->hasOption('all')) {
+ ImportCommLinksJob::dispatch(-1);
+ return Command::SUCCESS;
+ }
+
+ if (!$this->hasArgument('id')) {
+ $this->error('Missing Comm-Link ID argument.');
+
+ return Command::FAILURE;
+ }
+
$id = (int)$this->argument('id');
try {
@@ -49,13 +61,13 @@ public function handle(): int
if (count(Storage::disk('comm_links')->files($id)) === 0) {
$this->error('Comm-Link does not exist on \'comm_links\' disk.');
- return 1;
+ return Command::FAILURE;
}
$file = basename(Arr::last(Storage::disk('comm_links')->files($id)));
dispatch(new ImportCommLinkJob($id, $file, $commLink, true));
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/app/Console/Commands/Rsi/CommLink/Translate/TranslateCommLinks.php b/app/Console/Commands/Rsi/CommLink/TranslateCommLinks.php
similarity index 85%
rename from app/Console/Commands/Rsi/CommLink/Translate/TranslateCommLinks.php
rename to app/Console/Commands/Rsi/CommLink/TranslateCommLinks.php
index 48a22897d..d3716a1da 100644
--- a/app/Console/Commands/Rsi/CommLink/Translate/TranslateCommLinks.php
+++ b/app/Console/Commands/Rsi/CommLink/TranslateCommLinks.php
@@ -2,7 +2,7 @@
declare(strict_types=1);
-namespace App\Console\Commands\Rsi\CommLink\Translate;
+namespace App\Console\Commands\Rsi\CommLink;
use App\Console\Commands\Rsi\CommLink\AbstractCommLinkCommand as CommLinkCommand;
use App\Jobs\Rsi\CommLink\Translate\TranslateCommLinks as TranslateCommLinksJob;
@@ -43,8 +43,8 @@ public function handle(): int
$this->info('Including all Comm-Links');
}
- dispatch(new TranslateCommLinksJob($this->filterDirectories('comm_links', $modifiedTime)->toArray()));
+ TranslateCommLinksJob::dispatch($this->filterDirectories('comm_links', $modifiedTime)->toArray());;
- return 0;
+ return CommLinkCommand::SUCCESS;
}
}
diff --git a/app/Console/Commands/Rsi/CommLink/Wiki/CreateCommLinkWikiPages.php b/app/Console/Commands/Rsi/CommLink/Wiki/CreateCommLinkWikiPages.php
index 0bcd4ec20..90019dbad 100644
--- a/app/Console/Commands/Rsi/CommLink/Wiki/CreateCommLinkWikiPages.php
+++ b/app/Console/Commands/Rsi/CommLink/Wiki/CreateCommLinkWikiPages.php
@@ -31,8 +31,8 @@ public function handle(): int
{
$this->info('Dispatching Comm-Link Wiki Page Creation');
- dispatch(new \App\Jobs\Wiki\CommLink\CreateCommLinkWikiPages());
+ \App\Jobs\Wiki\CommLink\CreateCommLinkWikiPages::dispatch();
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/app/Console/Commands/Rsi/CommLink/Wiki/CreateCommLinkWikiTranslationPages.php b/app/Console/Commands/Rsi/CommLink/Wiki/CreateCommLinkWikiTranslationPages.php
index 06a644958..c9bcb2d80 100644
--- a/app/Console/Commands/Rsi/CommLink/Wiki/CreateCommLinkWikiTranslationPages.php
+++ b/app/Console/Commands/Rsi/CommLink/Wiki/CreateCommLinkWikiTranslationPages.php
@@ -33,6 +33,6 @@ public function handle(): int
\App\Jobs\Wiki\CommLink\CreateCommLinkWikiTranslationPages::dispatch();
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/app/Console/Commands/StarCitizen/ShipMatrix/Download/DownloadShipMatrix.php b/app/Console/Commands/StarCitizen/ShipMatrix/DownloadShipMatrix.php
similarity index 96%
rename from app/Console/Commands/StarCitizen/ShipMatrix/Download/DownloadShipMatrix.php
rename to app/Console/Commands/StarCitizen/ShipMatrix/DownloadShipMatrix.php
index 0a7840fd8..6437c8e01 100644
--- a/app/Console/Commands/StarCitizen/ShipMatrix/Download/DownloadShipMatrix.php
+++ b/app/Console/Commands/StarCitizen/ShipMatrix/DownloadShipMatrix.php
@@ -2,7 +2,7 @@
declare(strict_types=1);
-namespace App\Console\Commands\StarCitizen\ShipMatrix\Download;
+namespace App\Console\Commands\StarCitizen\ShipMatrix;
use App\Jobs\StarCitizen\Vehicle\CheckShipMatrixStructure;
use App\Jobs\StarCitizen\Vehicle\DownloadShipMatrix as DownloadShipMatrixJob;
diff --git a/app/Console/Commands/StarCitizen/ShipMatrix/Import/ImportShipMatrix.php b/app/Console/Commands/StarCitizen/ShipMatrix/ImportShipMatrix.php
similarity index 94%
rename from app/Console/Commands/StarCitizen/ShipMatrix/Import/ImportShipMatrix.php
rename to app/Console/Commands/StarCitizen/ShipMatrix/ImportShipMatrix.php
index 000150d05..0ad341b03 100644
--- a/app/Console/Commands/StarCitizen/ShipMatrix/Import/ImportShipMatrix.php
+++ b/app/Console/Commands/StarCitizen/ShipMatrix/ImportShipMatrix.php
@@ -2,7 +2,7 @@
declare(strict_types=1);
-namespace App\Console\Commands\StarCitizen\ShipMatrix\Import;
+namespace App\Console\Commands\StarCitizen\ShipMatrix;
use App\Jobs\StarCitizen\Vehicle\Import\ImportShipMatrix as ImportShipMatrixJob;
use Illuminate\Console\Command;
diff --git a/app/Console/Commands/StarCitizen/Starmap/Download/DownloadStarmap.php b/app/Console/Commands/StarCitizen/Starmap/DownloadStarmap.php
similarity index 97%
rename from app/Console/Commands/StarCitizen/Starmap/Download/DownloadStarmap.php
rename to app/Console/Commands/StarCitizen/Starmap/DownloadStarmap.php
index 2c74c40de..4b86707ed 100644
--- a/app/Console/Commands/StarCitizen/Starmap/Download/DownloadStarmap.php
+++ b/app/Console/Commands/StarCitizen/Starmap/DownloadStarmap.php
@@ -2,7 +2,7 @@
declare(strict_types=1);
-namespace App\Console\Commands\StarCitizen\Starmap\Download;
+namespace App\Console\Commands\StarCitizen\Starmap;
use App\Jobs\StarCitizen\Starmap\Download\DownloadStarmap as DownloadStarmapJob;
use App\Jobs\StarCitizen\Starmap\Import\ImportStarmap;
diff --git a/app/Console/Commands/StarCitizen/Starmap/Import/ImportStarmap.php b/app/Console/Commands/StarCitizen/Starmap/ImportStarmap.php
similarity index 91%
rename from app/Console/Commands/StarCitizen/Starmap/Import/ImportStarmap.php
rename to app/Console/Commands/StarCitizen/Starmap/ImportStarmap.php
index e13836802..6231e7a58 100644
--- a/app/Console/Commands/StarCitizen/Starmap/Import/ImportStarmap.php
+++ b/app/Console/Commands/StarCitizen/Starmap/ImportStarmap.php
@@ -1,6 +1,6 @@
-
+
@@ -66,9 +66,6 @@ MAIL_FROM_NAME=
MAIL_USERNAME=
MAIL_PASSWORD=
-# Max 10.000 Requests in one Second
-THROTTLE_GUEST_REQUESTS=10000
-THROTTLE_PERIOD=1
#WIKI_URL=https://star-citizen.wiki
#WIKI_API_URL=https://star-citizen.wiki/api.php
@@ -93,10 +90,6 @@ DEEPL_AUTH_KEY=
# Target language of DeepL Translations Default: DE
DEEPL_TARGET_LOCALE=
-# User account on RSI // Login currently BROKEN due to recaptcha
-RSI_USERNAME=
-RSI_PASSWORD=
-
SC_DATA_VERSION=3.13
```
@@ -187,7 +180,22 @@ All available commands can be listed by calling `php artisan`.
To get help for a specific command call `php artisan help COMMAND`.
+### Importing _all_ data
+To import all and everything you can run:
+```shell
+php artisan data:populate
+```
+
+This command will import _everything_ but will take multiple hours to days.
+You can alternatively skip some parts using the following options:
+- `--skipCommLinks`
+- `--skipGalactapedia`
+- `--skipStarmap`
+- `--skipScUnpacked`
+
### Comm-Links
+All Comm-Link commands require that the database is seeded using `php artisan db:seed`!
+
#### Import missing Comm-Links
Inside the container execute
```shell script
@@ -199,7 +207,7 @@ The import command can be safely stopped by `Ctrl+C`.
Comm-Links should be accessible through `API_URL/api/comm-links`.
#### Import downloaded Comm-Links
-Downloaded Comm-Links can be imported by calling `php artisan comm-links:import-all`.
+Downloaded Comm-Links can be imported by calling `php artisan comm-links:import --all`.
This command will dispatch parsing jobs for every downloaded Comm-Link found in `storage/app/comm_links`.
#### Download specific Comm-Links
@@ -217,6 +225,8 @@ Jobs are dispatched on the `comm_link_images` queue. This queue needs to be call
Command: `php artisan comm-links:images-create-metadata`.
Requests the following metadata for each image: `size`, `mime_type`, `last_modified`.
+Without the image metadata no images will be shown on the image index view.
+
#### Create Comm-Link Image hashes
Command: `php artisan comm-links:images-create-hashes`.
Creates image hashes used by the reverse image search. Requires present metadata.
@@ -250,6 +260,12 @@ php artisan galactapedia:import-properties
Articles should be accessible through `API_URL/api/galactapedia`
+### In-Game Items / Vehicles
+To import the data found in the scunpacked folder run:
+```shell
+php artisan sc:import-items
+```
+
### Schedule
The schedule container specified in `docker-compose` will run the following commands:
diff --git a/tests/Feature/Console/Commands/CommLink/Download/DownloadCommLinksTest.php b/tests/Feature/Console/Commands/CommLink/Download/DownloadCommLinksTest.php
deleted file mode 100644
index 7f520eccb..000000000
--- a/tests/Feature/Console/Commands/CommLink/Download/DownloadCommLinksTest.php
+++ /dev/null
@@ -1,28 +0,0 @@
-artisan('comm-links:download-all')
- ->expectsOutput('Downloading all Comm-Links')
- ->assertExitCode(0);
-
- Bus::assertDispatched(DownloadMissingCommLinks::class);
- }
-}
diff --git a/tests/Feature/Console/Commands/CommLink/Import/ImportCommLinkTest.php b/tests/Feature/Console/Commands/CommLink/Import/ImportCommLinkTest.php
index 4022c3913..93d309050 100644
--- a/tests/Feature/Console/Commands/CommLink/Import/ImportCommLinkTest.php
+++ b/tests/Feature/Console/Commands/CommLink/Import/ImportCommLinkTest.php
@@ -21,9 +21,18 @@ class ImportCommLinkTest extends TestCase
*/
public function testHandleMissingId(): void
{
- $this->expectException(RuntimeException::class);
+ $this->artisan('comm-links:import')->assertExitCode(1);
+ }
- $this->artisan('comm-links:import');
+ /**
+ * A basic feature test example.
+ *
+ * @return void
+ */
+ public function testHandleAllOption(): void
+ {
+ Bus::fake();
+ $this->artisan('comm-links:import --all')->assertExitCode(0);
}
/**
diff --git a/tests/Feature/Console/Commands/CommLink/Import/ImportCommLinksTest.php b/tests/Feature/Console/Commands/CommLink/Import/ImportCommLinksTest.php
deleted file mode 100644
index 6a1c091b3..000000000
--- a/tests/Feature/Console/Commands/CommLink/Import/ImportCommLinksTest.php
+++ /dev/null
@@ -1,53 +0,0 @@
-artisan('comm-links:import-all')
- ->expectsOutput('Dispatching Comm-Link Import')
- ->expectsOutput('Including all Comm-Links')
- ->assertExitCode(0);
-
- Bus::assertDispatched(ImportCommLinks::class);
- }
-
- public function testHandleOffset(): void
- {
- Bus::fake();
-
- $this->artisan('comm-links:import-all 10')
- ->expectsOutput('Dispatching Comm-Link Import')
- ->expectsOutput("Including Comm-Links that were created in the last '10' minutes")
- ->assertExitCode(0);
-
- Bus::assertDispatched(ImportCommLinks::class);
- }
-
- public function testHandleOffsetGreaterThan0(): void
- {
- Bus::fake();
-
- $this->artisan('comm-links:import-all 12700')
- ->expectsOutput('Dispatching Comm-Link Import')
- ->expectsOutput("Including Comm-Links that were created in the last '12700' minutes")
- ->assertExitCode(0);
-
- Bus::assertDispatched(ImportCommLinks::class);
- }
-}