diff --git a/src/app/Jobs/ImportFromApiJob.php b/src/app/Jobs/ImportFromApiJob.php index a4efddf..4a60bc4 100644 --- a/src/app/Jobs/ImportFromApiJob.php +++ b/src/app/Jobs/ImportFromApiJob.php @@ -41,7 +41,7 @@ public function handle(): void // replace with switch statement once more sources are added if ($this->source == ImportSources::OPEN_LIBRARY) { - $this->importOpenLibrary($this->query); + $this->importOpenLibrary(); } } } diff --git a/src/app/Traits/Imports/OpenLibraryTrait.php b/src/app/Traits/Imports/OpenLibraryTrait.php index f26d10c..a0cdd86 100644 --- a/src/app/Traits/Imports/OpenLibraryTrait.php +++ b/src/app/Traits/Imports/OpenLibraryTrait.php @@ -10,7 +10,13 @@ trait OpenLibraryTrait { use CommonLibraryTrait; - public function importOpenLibrary($tries = 3) { + + /** + * @param $tries int The amount of times the import should be tried. + * @return void Imports books from OpenLibrary. + */ + public function importOpenLibrary(int $tries = 3): void + { if ($tries < 1) $tries = 3; $maxOffset = (int) ceil(100 * $tries / 100) * 100; diff --git a/src/database/migrations/2024_01_22_120757_failed_jobs.php b/src/database/migrations/2024_01_22_120757_failed_jobs.php new file mode 100644 index 0000000..0285366 --- /dev/null +++ b/src/database/migrations/2024_01_22_120757_failed_jobs.php @@ -0,0 +1,32 @@ +id(); + $table->string('uuid')->unique(); + $table->text('connection'); + $table->text('queue'); + $table->longText('payload'); + $table->longText('exception'); + $table->timestamp('failed_at')->useCurrent(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('failed_jobs'); + } +};