0.1.2
This commit is contained in:
51
app/Jobs/ImageUpsert.php
Normal file
51
app/Jobs/ImageUpsert.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Image;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ImageUpsert implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public int $comicId,
|
||||
public int $chapterId,
|
||||
public array $chapter
|
||||
){}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
Log::info("JOB ImageUpsert START, comicId: {$this->comicId}, chapterId: {$this->chapterId}");
|
||||
|
||||
$arrayForUpsert = [];
|
||||
|
||||
foreach ($this->chapter['sorted'] as $k => $image) {
|
||||
$metadata = $this->chapter;
|
||||
unset($metadata['sorted']);
|
||||
unset($metadata['chapter']['contents'], $metadata['chapter']['words']);
|
||||
|
||||
$arrayForUpsert[] = [
|
||||
'comic_id' => $this->comicId,
|
||||
'chapter_id' => $this->chapterId,
|
||||
'order' => $k,
|
||||
'url' => $image['url'],
|
||||
'metadata' => json_encode($metadata),
|
||||
];
|
||||
}
|
||||
|
||||
// Do an upsert
|
||||
Image::upsert($arrayForUpsert, uniqueBy: 'url');
|
||||
|
||||
Log::info('JOB ImageUpsert END');
|
||||
}
|
||||
}
|
||||
51
app/Jobs/RemotePrefetch.php
Normal file
51
app/Jobs/RemotePrefetch.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Remote\CopyManga;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RemotePrefetch implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(public string $action, public array $parameters = [])
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$copyManga = new CopyManga();
|
||||
|
||||
switch ($this->action) {
|
||||
case 'chapter':
|
||||
Log::info("JOB RemotePrefetch START, action '{$this->action}', Pathword: {$this->parameters['pathword']}, UUID: {$this->parameters['uuid']}");
|
||||
|
||||
$copyManga->chapter($this->parameters['pathword'], $this->parameters['uuid']);
|
||||
|
||||
Log::info("JOB RemotePrefetch END, action '{$this->action}'");
|
||||
break;
|
||||
case 'chapters':
|
||||
// TODO:
|
||||
break;
|
||||
case 'index':
|
||||
// TODO
|
||||
break;
|
||||
case 'tags':
|
||||
// TODO
|
||||
break;
|
||||
default:
|
||||
Log::info("JOB RemotePrefetch Unknown action '{$this->action}'");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user