Skip to content

Commit

Permalink
fix: Fixes job
Browse files Browse the repository at this point in the history
BEWARE: Please first review and push #37 before pushing this one. #37 has fixes that this pr depends on it.
  • Loading branch information
Timtendo12 committed Jan 22, 2024
1 parent 5729b51 commit 6614722
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/Jobs/ImportFromApiJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
8 changes: 7 additions & 1 deletion src/app/Traits/Imports/OpenLibraryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
32 changes: 32 additions & 0 deletions src/database/migrations/2024_01_22_120757_failed_jobs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->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');
}
};

0 comments on commit 6614722

Please sign in to comment.